• Resolved xberg

    (@xberg)


    Hello,
    I searched mailpoet 3 support pages but was unable to find documentation on mailpoet verbs to subscribe / unsubscribe / display existing lists through plain WP php custom code. I am integrating Mailpoet in my code.
    Could you please point me in the right direction?
    thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter xberg

    (@xberg)

    I am looking for this documentation, but for V3:
    http://docs.mailpoet.com/article/67-plugin-form-integrate

    I have a similar problem. Please let me know if you find a solution.

    Best regards,

    Neil.

    Here is the thread:

    https://wordpress.org/support/topic/add-subscriber-with-php/

    Best regards,

    Neil.

    Hello –

    Could you please post the complete php script with headers and includes?

    <?php

    ?>

    Many thanks,

    Neil.

    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’ => ‘test@example.com’,
    ‘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.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘API / Php verbs for subscribe / unsubscribe / lists’ is closed to new replies.