I am trying to insert a string through a variable into a custom field.
$contact->custom_fields = array(array('name' => 'CustomField1', 'value' => $_POST['type_of_book']));
Inserts fine.
The code below:
$foo=$_POST['type_of_book'];
$contact->custom_fields = array(array('name' => 'CustomField1', 'value' => $foo));
Results in the following error msg.
[error_key] => json.type.invalid [error_message] => #/custom_fields/0/value: Value is of a disallowed type. Allowed types are: Null, String.
I need the variable because the it will contain multiple values from an imploded checkbox array.
Please advise why this generates an error?
What is the value of $foo? If it is a boolean (true/false), PHP will serialize that to a boolean JSON value which is not valid for that field. You would need to pass in a string value for true/false if you wanted to store that in the custom field.
The holidays have come and gone. For many seasonal businesses, this means the rush of shoppers has decreased as well. Instead of turning off the lights and waiting for spring, make your email marketi...
See Article