You can quickly add subscribers in Mailster with some lines of code.

The quickest way is to add a single email address.

mailster( 'subscribers' )->add( '[email protected]' );

This method will return the ID of the subscriber or a WP_Error object if something fails.

Add a Subscriber with additional info

If you have more info, you can use an array as the first argument

$subscriber_id = mailster('subscribers')->add(array(
    'firstname' => 'John',
    'lastname' => 'Doe',
    'email' => '[email protected]',
    'status' => 1, //1 = subscribed (default) , 0 = pending, 2 = unsubscribed, 3 = hardbounced
    'custom-field' => 'Custom Value',
    'referer' => 'Your referer' //default = $_SERVER['REQUEST_URI']
), $overwrite );

Update a Subscriber

You need the subscriber ID to update a subscriber.

mailster('subscribers')->update( array(
    'ID' => 123,
    'firstname' => 'Jane',
) );

Assign lists

To assign lists, you can use the assign_lists method like

$success = mailster('subscribers')->assign_lists( $subscriber_ids, $lists, $remove_old );
  • $subscriber_ids is either a single ID or an array with ids of subscribers
  • $lists is either a single id or an array with ids of lists
  • $remove_old will remove all assigned lists before assigning the new ones (default false)
  • $success is boolean

Remove a Subscriber

To remove a subscriber ,you can do

mailster('subscribers')->remove( $subscriber_ids )
  • $subscriber_ids can either be a single subscriber ID or an array of IDs.

Learn more about Mailster for Developers.