If I am using the basic API v2 PHP example, addOrUpdateContact.php and I want to add the value of a radio input to a custom field named CustomField1, can I not just post like so?
$contact = new Contact(); $contact->addEmail($_POST['email']); $contact->addList($_POST['list']); $contact->first_name = $_POST['first_name']; $contact->last_name = $_POST['last_name']; $contact->CustomField1 = $_POST['CustomField1'];
When I try that, I receive the error.
How do I post to CustomField1?
I have limited knowledge of PHP and/or this API but this seems too simple to not work.
Solved! Go to Solution.
Hello,
Thank you for reaching out to Constant Contact developer support.
There is a custom field array that then contains each custom field within it as a sub-object. This is the same way that lists work on contact objects. See below:
$contact->custom_fields = [
[
"name"=>"CustomField1",
"Value"=>$_POST['CustomField1']
],
[
"name"=>"CustomField2",
"Value"=>$_POST['CustomField2']
]
];
Regards,
David B.
Tier II API Support Engineer
Hello,
Thank you for reaching out to Constant Contact developer support.
There is a custom field array that then contains each custom field within it as a sub-object. This is the same way that lists work on contact objects. See below:
$contact->custom_fields = [
[
"name"=>"CustomField1",
"Value"=>$_POST['CustomField1']
],
[
"name"=>"CustomField2",
"Value"=>$_POST['CustomField2']
]
];
Regards,
David B.
Tier II API Support Engineer