iHateQuesting
Member
Hi there,
I looked around and searched a lot to find information on this, but was unable to deduct how the
XF:Thread\Creator ->setcustomFields(array) works exactly
I've tried the following...
	
	
	
		
But, unfortunately for me, this creates the thread with a blank value for the custom field with fieldId "mykeytest".
Could anyone help in answering what is the correct way to pass custom fields to the setCustomFields(array) parameter?
Thank you!
				
			I looked around and searched a lot to find information on this, but was unable to deduct how the
XF:Thread\Creator ->setcustomFields(array) works exactly
I've tried the following...
		PHP:
	
	$user = \XF::em()->find('XF:User', $data['user_id']);
$forum = \XF::em()->find('XF:Forum', $data['forum_id']);
\XF::asVisitor($user, function() use ($forum, $data) {
    $creator = \XF::service('XF:Thread\Creator', $forum);
    $creator->setContent($data['title'], $data['message']);
    $creator->setCustomFields([
           'mykeytest' => "testing value"
    ]);
    $creator->setIsAutomated();
    $creator->save();
});
	But, unfortunately for me, this creates the thread with a blank value for the custom field with fieldId "mykeytest".
Could anyone help in answering what is the correct way to pass custom fields to the setCustomFields(array) parameter?
Thank you!