Created
February 26, 2020 18:20
-
-
Save jonpasquier/82a98db75616bc12d241c15d5bd178fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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