Support » Plugin: Add-on Contact Form 7 - MailPoet 3 » Mailpoet function [mpunsub mpunsub] is not working

  • Peter Smits

    (@psmits1567)


    Hi

    I am using your addon for mailpoet contact form 7 mailpoet addon
    With your contactform you can unsubscribe with function [mpunsub mpunsub]
    But this does no longer work, it throws an error like below
    [05-Apr-2020 22:07:43 UTC] PHP Notice: Object of class MailPoet\Models\Subscriber could not be converted to int in /www/wp-content/plugins/mailpoet/lib/Models/Subscriber.php on line 62
    [05-Apr-2020 22:07:43 UTC] PHP Warning: trim() expects parameter 1 to be string, object given in /www/wp-content/plugins/mailpoet/lib/Models/Subscriber.php on line 64

    It seems the parameter passed on has the wrong content
    Can you have a look at this behavior ?
    Regards,
    Peter

Viewing 6 replies - 1 through 6 (of 6 total)
  • Kamrul@Tikweb

    (@abdultikweb)

    Hello, thanks for reporting. We will check the issue.

    Thanks

    Peter Smits

    (@psmits1567)

    Hi
    I reported this problem at Mailpoet also, but they answered me to report it to you also. So currently Mailpoet does not take any action to research this issue

    Regards,

    Peter Smits

    (@psmits1567)

    Hi Kamrul

    It took me some hours but I got it working again
    With the below code the subscriber is unsubscribed from all list he was connected to
    Maybe you can see what was wrong with the original code
    I beleave the lists variable was not populated properly
    I also changed it to unsubscribe from all lists

    public function unsubscribe_email( $form_data ) {
    if ( isset( $form_data[‘unsubscribe-email’] ) ) {
    if ( isset( $form_data[‘your-email’] ) ) {
    $mailpoet_api = \MailPoet\API\API::MP(‘v1’);
    $subscriber_email = $form_data[‘your-email’];
    //error_log(” email: $subscriber_email”);
    $subscriber = Subscriber::findOne( $subscriber_email );

    if ( $subscriber !== false ) {
    $subscriber->withSubscriptions();
    $current_lists =$subscriber->subscriptions;
    foreach ( $current_lists as $key => $value ) {
    $list_ids[] = $value[‘segment_id’];
    }
    $email= $subscriber->email;
    try {
    $subscriber = $mailpoet_api->unsubscribeFromLists($email,$list_ids );
    return true;

    } catch(Exception $e) {
    $error = $e->getMessage();
    error_log(” error api :$error”);
    return $error;
    }
    } return false;

    }
    }

    return false;
    } // End of unsubscribe_email

    Peter Smits

    (@psmits1567)

    Hi Kamrul

    I added another code to set the state of the subscriber to unsubscribed.
    It has no use to leave the state subscribed if no lists are connected.
    $subscriber = $mailpoet_api->unsubscribeFromLists($email,$list_ids );
    //Set state to unsubscribed
    $signup_confirm_state = ‘unsubscribed’;
    $subscribe_data = array(
    ’email’ => $subscriber_email,
    ‘status’ => $signup_confirm_state,
    );
    $subscribe_data[‘status’] = $signup_confirm_state;
    try {

    //Update the status
    $res=Subscriber::createOrUpdate( $subscribe_data );
    }catch(Exception $e) {
    $error = $e->getMessage();
    error_log(” error api :$error”);
    return $error;
    }

    I think this will improve usage of the plugin
    Peter

    Hello Peter, thank you for your input. We are currently investigating the issue and we will release the fix in our next update.

    Thank you

    Hi

    Any news about this issue ?
    Currently my subscribers cannot unsubscribe, so it is important to get it fixed officially
    Thanks for your help
    Peter

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.