Hello –
I have the following but it is not working correctly:
<?php
require_once( “/path/to/httpdocs/wp-load.php” );
$mp_subscriber_data = array(
’email’ => ‘[email protected]’,
‘first_name’ => ‘John’,
‘last_name’ => ‘Doe’,
);
$mp_list = 2; // you can get available list IDs by using the \MailPoet\API\API::MP(‘v1’)->getLists(); method
$mp_options = array(
// default: true
“send_confirmation_email” => “false”,
// default: true
“schedule_welcome_email” => “false”,
);
try {
$mp_subscriber = \MailPoet\API\API::MP(‘v1’)->subscribeToList($mp_subscriber_data, $mp_list, $mp_options);
//$mp_subscriber = \MailPoet\API\API::MP(‘v1’)->subscribeToList($mp_subscriber, $mp_list);
} catch(Exception $exception) {
return $exception->getMessage();
}
?>
I have the following error:
PHP Warning: trim() expects parameter 1 to be string, array given in /path/to/httpdocs/wp-content/plugins/mailpoet/lib/Models/Subscriber.php on line 31
Running it on the commnd line with:
php script_name.php
Any ideas on how I can resolve this?
Regards,
Neil.