Hello,
I’m trying to create a little script that will add an entry using PHP. This is a simple task until I have a custom field with a third-party field type, in this case a Cartthrob package field. The script I’ve written below will create the entry, but leaves the custom field empty.
Can you help me work out how to add content to this custom field using PHP?
Many thanks,
Mike
<?php
$channel_id = 14;
$package_products = array ( 0 => array ( 'entry_id' => '36', 'description' => '', ), 1 => array ( 'entry_id' => '37', 'description' => '', ), );
$this->EE->load->library('api');
$this->EE->api->instantiate('channel_entries');
$this->EE->api->instantiate('channel_fields');
$data = array(
'title' => 'PHP Added an Entry!',
'entry_date' => '1256953732',
'field_id_96' => base64_encode(serialize($package_products)),
'field_ft_96' => 'none'
);
$this->EE->api_channel_fields->setup_entry_settings($channel_id, $data);
if ($this->EE->api_channel_entries->submit_new_entry($channel_id, $data) === FALSE)
{
show_error('An Error Occurred Creating the Entry');
}
?>
[Mod Edit: Moved to the Development and Programming forum]
