• Resolved devilboss

    (@devilboss)


    Hello,

    I just wanted to subscribe a user from the functions.php file. I tried this, but it didn’t work.

    $list_id = “b4b88797bj”;
    $email = $info->user_email;
    $api = mc4wp_get_api_v3();
    $api->add_list_member( $list_id, [ ’email_address’ => ‘[email protected]’ ]);

    Also I couldn’t find any documentation about that. The website developer.mc4wp.com don’t work neither

    Thanks in advance for your help

    • This topic was modified 7 years, 9 months ago by devilboss.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Danny van Kooten

    (@dvankooten)

    Hi devilboss,

    Most likely, you’ll have to include a status field which indicates whether the subscriber is subscribed immediately or pending (meaning they’ll have to confirm their email address first).

    
    $list_id = “b4b88797bj”;
    $email = $info->user_email;
    $api = mc4wp_get_api_v3();
    $api->add_list_member( $list_id, [ "email_address" => "[email protected]", "status" => "pending" ]);
    
    Thread Starter devilboss

    (@devilboss)

    Thanks so much Danny for your help. It works !

    How do you add the first name and last name, I tried this but it didn’t work and couldn’t find any doc online :

    $api->add_list_member( $list_id, [ “email_address” => “[email protected]”, “status” => “subscribed”, “FNAME” => “John”, “LNAME” => “Markus” ]);

    Thanks in advance for your help

    Plugin Contributor Lap

    (@lapzor)

    Plugin Author Danny van Kooten

    (@dvankooten)

    Hi Devilboss,

    Sorry for the delayed reply. Here’s how that would look:

    
    $list_id = “b4b88797bj”;
    $email = $info->user_email;
    $api = mc4wp_get_api_v3();
    $api->add_list_member( $list_id, [ 
       "email_address" => "[email protected]", 
       "merge_fields" => (object) [
          "FNAME" => "Devil",
          "LNAME" => "Boss",
       ],
       "status" => "pending" 
    ]);
    

    Hope that helps!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Adding to a list a user from functions.php’ is closed to new replies.