Plugin Directory

Changeset 2321619


Ignore:
Timestamp:
06/10/2020 01:40:33 PM (6 years ago)
Author:
ehsantikweb
Message:

Fix mail not sent issue if subscriber exist and the language is not english, and taging version 1.1.12

Location:
add-on-gravity-forms-mailpoet
Files:
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • add-on-gravity-forms-mailpoet/trunk/add-on-gravity-forms-mailpoet.php

    r2128484 r2321619  
    33 * Plugin Name:       Add-on Gravity Forms - Mailpoet 3
    44 * Description:       Add a MailPoet 3 signup field to your Gravity Forms.
    5  * Version:           1.1.12
     5 * Version:           1.1.13
    66 * Author:            Tikweb
    77 * Author URI:        http://www.tikweb.dk/
     
    398398            $mailpoetlists = array_unique(array_merge( $mailpoetlists, $list_ids ));
    399399        }
    400                    
     400
    401401        /* Fix added end. Version 1.1.6 */
    402402
     
    452452        } catch ( Exception $exception ) {
    453453
    454             if ( 'This subscriber already exists.' == $exception->getMessage() ) {
     454
     455            //==  Below code is modifed in version 1.1.13 by k4mrul  ==\\
     456
     457            //If subscriber already exist
     458            if ( 12 == $exception->getCode() ) {
    455459                try {
    456                     $subscriber_data['status']          = 'unconfirmed';
    457                     Subscriber::createOrUpdate( $subscriber_data );
    458                     $subscriber = \MailPoet\API\API::MP( 'v1' )->subscribeToLists( $subscriber_data['email'], $mailpoetlists, $options['send_confirmation_email'] = true );
     460                    //If subscriber already exist, simply add subscriber to the new list. Subscriber status will be subscribed as s/he already confirmed email. s/he may get a new mail from mailpoet for confirmation but s/he already considered as subscribed
     461                    $existingUser = \MailPoet\API\API::MP( 'v1' )->getSubscriber($subscriber_data['email']);
     462
     463                    \MailPoet\API\API::MP( 'v1' )->subscribeToLists($existingUser['subscriptions'][0]['subscriber_id'], $mailpoetlists , $options['send_confirmation_email'] = true);
     464
     465                    //Previous code. Previously we make the subscriber status unconfirmed and let him/her to confirm the email for new list. But that's not how mailpoet's default behavior works. So we respected default behavior
     466                    //$subscriber_data['status']          = 'unconfirmed';
     467                    //Subscriber::createOrUpdate( $subscriber_data );
     468                    //$subscriber = \MailPoet\API\API::MP( 'v1' )->subscribeToLists( $subscriber_data['email'], $mailpoetlists, $options['send_confirmation_email'] = true );
    459469
    460470                } catch ( Exception $exception ) {
     
    469479
    470480//Deprecated:
    471 /*      $subscriber_data['segments'] = $mailpoetlists;
    472 
    473 
    474         $subscriber          = Subscriber::createOrUpdate( $subscriber_data );
    475         $sagments            = $subscriber->segments()->findMany();
    476         $notification_sender = new NewSubscriberNotificationMailer();
    477 
    478         if ( ! empty( $subscriber ) ) {
    479 
    480             $subscriber_status = Subscriber::whereEqual( 'email',
    481                 $email )->whereEqual( 'status', 'subscribed' )->findArray();
    482 
    483             //If the subscriber is new, send email confirmation to subscribe for the list. Otherwise, if subscriber already confirm the email for another list and subscribe to the new list, don't send confirmation email again.
    484             if ( empty( $subscriber_status[0]['confirmed_ip'] ) ) {
    485                 $confirmation_sender = new ConfirmationEmailMailer();
    486                 $confirmation_sender->sendConfirmationEmail( $subscriber );
    487             } //Notify the admin that existed subscriber subscribed to the new list
    488             else {
    489                 $notification_sender->send( $subscriber, $sagments );
    490             }
    491         }*/
    492     }
    493 }
     481        /*      $subscriber_data['segments'] = $mailpoetlists;
     482
     483
     484                $subscriber          = Subscriber::createOrUpdate( $subscriber_data );
     485                $sagments            = $subscriber->segments()->findMany();
     486                $notification_sender = new NewSubscriberNotificationMailer();
     487
     488                if ( ! empty( $subscriber ) ) {
     489
     490                    $subscriber_status = Subscriber::whereEqual( 'email',
     491                        $email )->whereEqual( 'status', 'subscribed' )->findArray();
     492
     493                    //If the subscriber is new, send email confirmation to subscribe for the list. Otherwise, if subscriber already confirm the email for another list and subscribe to the new list, don't send confirmation email again.
     494                    if ( empty( $subscriber_status[0]['confirmed_ip'] ) ) {
     495                        $confirmation_sender = new ConfirmationEmailMailer();
     496                        $confirmation_sender->sendConfirmationEmail( $subscriber );
     497                    } //Notify the admin that existed subscriber subscribed to the new list
     498                    else {
     499                        $notification_sender->send( $subscriber, $sagments );
     500                    }
     501                }*/
     502    }
     503}
  • add-on-gravity-forms-mailpoet/trunk/changelog.txt

    r2128484 r2321619  
    11== Changelog ==
     2
     3= 1.1.13 - 2020-06-08 =
     4* Fix mail not sent issue if subscriber exist and the language is not english
    25
    36= 1.1.12 - 2019-07-25 =
     
    6669= x.0.0 =
    6770* There are nothing else needed, than upgrading from the WordPress plugins screen.
     71
  • add-on-gravity-forms-mailpoet/trunk/class-gfnewmailpoetaddon.php

    r2128484 r2321619  
    204204        } catch ( Exception $exception ) {
    205205
    206             if ( 'This subscriber already exists.' == $exception->getMessage() ) {
     206            //If subscriber already exist
     207            if ( 12 == $exception->getCode() ) {
    207208                try {
    208                     if ($skipEmailValidation) {
    209                         $subscriber_data['status']          = 'subscribed';
    210                         Subscriber::createOrUpdate( $subscriber_data );
    211                     }
    212                     else {
    213                         $subscriber_data['status']          = 'unconfirmed';
    214                         Subscriber::createOrUpdate( $subscriber_data );
    215                         $subscriber = \MailPoet\API\API::MP( 'v1' )->subscribeToLists( $subscriber_data['email'], $mailpoetlists, $options['send_confirmation_email'] = true );
    216                     }
     209
     210                    //==  Below code is modifed in version 1.1.13 by k4mrul  ==\\
     211
     212                    //If subscriber already exist, simply add subscriber to the new list. Subscriber status will be subscribed as s/he already confirmed email. s/he may get a new mail from mailpoet for confirmation but s/he already counted as subscribed
     213                    $existingUser = \MailPoet\API\API::MP( 'v1' )->getSubscriber($subscriber_data['email']);
     214
     215                    \MailPoet\API\API::MP( 'v1' )->subscribeToLists($existingUser['subscriptions'][0]['subscriber_id'], $mailpoetlists , $options);
     216
     217                    //Previous code. Previously we make the subscriber status unconfirmed and let him/her to confirm the email for new list. But that's not how mailpoet's default behavior works.
     218
     219//                  if ($skipEmailValidation) {
     220//                      $subscriber_data['status']          = 'subscribed';
     221//                      Subscriber::createOrUpdate( $subscriber_data );
     222//                  }
     223//                  else {
     224//                      $subscriber_data['status']          = 'unconfirmed';
     225//                      Subscriber::createOrUpdate( $subscriber_data );
     226//                      $subscriber = \MailPoet\API\API::MP( 'v1' )->subscribeToLists( $subscriber_data['email'], $mailpoetlists, $options['send_confirmation_email'] = true );
     227//                  }
    217228
    218229
  • add-on-gravity-forms-mailpoet/trunk/readme.txt

    r2128484 r2321619  
    44Tags: mailpoet, gravity forms, gravityforms, form, forms, contact form, wysija, woocommerce, e-commerce, mail, email, e-mail, extension, add-on, newsletter, newsletters, subscription, checkout, list, lists, double opt-in
    55Requires at least: 4.6
    6 Tested up to: 5.2.2
     6Tested up to: 5.3.2
    77Requires PHP: 5.2
    8 Stable tag: 1.1.12
     8Stable tag: 1.1.13
    99
    1010Create MailPoet 3 newsletter subscribers from Gravity Form entries.
Note: See TracChangeset for help on using the changeset viewer.