Skip to content

Instantly share code, notes, and snippets.

@jonpasquier
Created February 26, 2020 18:20
Show Gist options
  • Save jonpasquier/82a98db75616bc12d241c15d5bd178fd to your computer and use it in GitHub Desktop.
Save jonpasquier/82a98db75616bc12d241c15d5bd178fd to your computer and use it in GitHub Desktop.
/**
* Add subscriber info to the desired lists when submission is complete.
*/
public function process_feed( $feed, $entry, $form ) {
..............
try {
$subscriber_data = \MailPoet\API\API::MP( 'v1' )->addSubscriber( $subscriber_data, $mailpoetlists,
$options );
} catch ( Exception $exception ) {
// if ( 'This subscriber already exists.' == $exception->getMessage() ) {
if ( 12 == $exception->getCode() ) {
try {
if ($skipEmailValidation) {
$subscriber_data['status'] = 'subscribed';
Subscriber::createOrUpdate( $subscriber_data );
}
else {
$subscriber_data['status'] = 'unconfirmed';
Subscriber::createOrUpdate( $subscriber_data );
$subscriber = \MailPoet\API\API::MP( 'v1' )->subscribeToLists( $subscriber_data['email'], $mailpoetlists, $options['send_confirmation_email'] = true );
}
} catch ( Exception $exception ) {
}
} else {
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment