• Resolved dreambuilders

    (@dreambuilders)


    Hello,

    I want to use this plugin to allow someone to signup for a drip campaign.

    The user completed the first name, last name, and email. The box is checked for the appropriate list, however when you submit the form the user in mailpoet is shown as unconfirmed. Is there any way when you submit the form to allow for the new subscriber to be auto-confirmed so it will trigger the mail poet series of emails?

    Thanks

Viewing 15 replies - 16 through 30 (of 32 total)
  • Hi Dreambuilder

    I got it working now with some changes.
    It appears that the call to add subscribers has been changed in mailpoet
    The plugin should use
    $subscriber = \MailPoet\API\API::MP(‘v1’)->addSubscriber($subscribe_data, $list_ids,$options);

    So I altered the code to handle this.
    Unfortunately it is more than a couple of lines.
    At the beginning of the program you need to add the following lines

    use MailPoet\Settings\SettingsController;
    use MailPoet\Subscribers\ConfirmationEmailMailer;

    The check these lines

    #Get custom fields and fields type
    $fields = CustomField::findMany();
    $results = array();
    $results_type = array();
    foreach ( $fields as $field ) {
    $results[ ‘cf_’ . $field->id ] = $field->name;
    $results_type[ ‘cf_’ . $field->id ] = $field->type;
    }
    // check the setting of mailpoet
    $this->settings = new SettingsController();
    $signup_confirmation = $this->settings->get(‘signup_confirmation’);
    if ((bool)$signup_confirmation[‘enabled’] == false) {
    $stat=’subscribed’;
    }
    else {
    $stat=’unconfirmed’;
    }
    if ( ! empty( $list_ids ) && is_array( $list_ids ) ) {
    $subscribe_data = array(
    ’email’ => $email,
    ‘segments’ => $list_ids,
    ‘first_name’ => $firstname,
    ‘last_name’ => $lastname,
    ‘status’ => $stat,
    );

    Then check these lines
    // Save subcriber data
    // This is the old way to subscribe !!
    /** $subscriber = Subscriber::createOrUpdate( $subscribe_data ); */
    // This needs to be extended because now there is never send an confirmation email !!
    // A check needs to be added wether to send a confirmation email or not, if so the value of send_confirmation_email should be set to true !!

    $options = array(
    ‘send_confirmation_email’ => false,
    ‘schedule_welcome_email’ => true
    );
    try {
    $subscriber = \MailPoet\API\API::MP(‘v1’)->addSubscriber($subscribe_data, $list_ids,$options);
    }
    catch(Exception $exception) {
    return $exception->getMessage();
    }
    // the code below is no longer necessary
    // if an error is caught then it should be displayed in future !!
    /**if ( ! $subscriber ) { */
    /** return; */
    /**} */

    // this is no longer necessary as it is handled by the API
    //Send subscriber a welcome mail
    //$sender = new ConfirmationEmailMailer();
    //$sender->sendConfirmationEmail( $subscriber );

    Thread Starter dreambuilders

    (@dreambuilders)

    I’m glad to hear you got this working!

    What file did you alter this code in and did you also keep this in place from your previous message?

    <blockquoteI altered the following code in /www/wp-content/plugins/add-on-contact-form-7-mailpoet/includes/class-mailpoet-cf7-submit-form.php
    The code starts at line 178
    if ( ! empty( $list_ids ) && is_array( $list_ids ) ) {
    $subscribe_data = array(
    ’email’ => $email,
    ‘segments’ => $list_ids,
    ‘first_name’ => $firstname,
    ‘last_name’ => $lastname,
    ‘status’ => ‘subscribed’,
    );
    Where status was ‘unconfirmed” into ‘subscribed’
    Now the status is ‘subscribed’ after the subscriber populates the form
    So this needs to be corrected by the plugin maker!

    Hi Dreambuilder,

    It is the same file where we made the change before. And I kept the previous change in place.
    But I suspect that with the new call it might not be necessary anymore. I did not check that after I got it working.

    Hello,

    Sorry for late reply. We were on vacation. Anyway, we will look for the issue and fix it very soon. Thank you

    Hi Tikweb

    That would be great as the plugin now uses an old method for updating/ inserting subscribers.
    That will be removed in Mailpoet at some point, and then your plugin will not work anymore.
    One remark to the changes I made, if a user already exists then his state will be altered to subscribed. The question is in this case is that ok. What if a user has unsubscribed before, and subscribes again. Now no warning is given, the message is suppressed by the way the results of subscription are handled.

    Hello @psmits1567, thank you for notifying. We will use the API method for adding/updating the subscribers. Your solution is working quite great. We will modify it and release the next version soon with the fix. Thanks for your time.

    Hi adultikweb,

    Thanks for the quick support!
    I will see the new version coming??
    Have a nice day!
    Peter

    Hi Dreambuilders,

    Glad that I could help you??
    It was fun to research and resolve.

    Thread Starter dreambuilders

    (@dreambuilders)

    Hello,

    Thank you for updating the plugin, however it is not working for me now. When I updated the plugin. I tested the form and when I click submit, it just hangs there and goes nowhere. The spinning circle thing after hitting the submit button just rotates and rotates.

    I rolled back to the previous version and the submit button works again.

    This is what my form looks like:

    If you need me to update the form please let me know:

    
    [text* firstname placeholder "First Name"]
    
    [text* lastname placeholder "Last Name"]
    
    [email* your-email placeholder "Email"]
    
    [mailpoetsignup* mailpoetsignup-737 list:46 default:on "Test Campaign"]
    
    [mpconsent mpconsent-134 privacypage:https://domain.com/policies-terms-conditions/ "By subscribing you agree to receive our newsletters and agree with our {privacypage}. You may unsubscribe at any time."]
    
    [submit "Subscribe"]
    Thread Starter dreambuilders

    (@dreambuilders)

    I think I know what it might be. The version I did the test on was using the previous version of MailPoet, so I will test it tonight after updating it. Thanks.

    Hi Dreambuilders,

    Luckely I tested the update with my existing form, and know that the fix in principle does work. I do not have the concent line in my form, but I do not believe that it causes your problem. If the screen does not stop spinning, you probably have an error in your log file. If you do not have “debug” set to on, please activate it and test again.
    An other possebility is that the change is causing a conflict with another plugin. To check that you need to disable as much plugins as possible and test again.

    Hi

    I tested with the latest version of Mailpoet!
    What do you mean with previous version?
    I thought I would let you know this.

    Thread Starter dreambuilders

    (@dreambuilders)

    I did not have version 3.28 of MailPoet installed, but I will try that tonight and test it out.

    Ok good luck

    Thread Starter dreambuilders

    (@dreambuilders)

    It works fine now! The problem was related to the older version of MailPoet. I simply updated that version, updated this plugin and it worked with no problem.

    Thank you again Peter and Tiki

Viewing 15 replies - 16 through 30 (of 32 total)
  • The topic ‘Auto-confirmation’ is closed to new replies.