Patch – Email confirmation not sent
-
Hi,
We have detected that for some months the pluguin stopped sending MailPoet confirmation mail.
After analyzing the situation we have seen that the problem comes from the file: /wp-content/plugins/add-on-gravity-forms-mailpoet/class-gfnewmailpoetaddon.php
The process_feed function try to add the subscriber and check if there the subsriber exists analyzing the exception thrown by the addSubscriber method (L82 – L228):
/** * 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() ) { 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 { } } }
The problem is that if you use MailPoet in a language that is not english, the exception message is translated and the code won’t run as intended!!!
MailPoet documentation states that they return special code depending of the type of error:
https://github.com/mailpoet/mailpoet/blob/master/doc/api_methods/AddSubscriber.mdSo, this problem can be corrected changing line 206 from
if ( 'This subscriber already exists.' == $exception->getMessage() ) {
to
if ( 12 == $exception->getCode() ) {
We have patched our plugin with success and the plugin is now running correctly.
Hope you can include the fix in a future release!
Regards,
Jonathan
- The topic ‘Patch – Email confirmation not sent’ is closed to new replies.