• Resolved cboom

    (@cboom)


    I am using the “MailChimp User Sync” plugin to sync different user meta tags to different list fields and everything works fine.

    However, I need to sync a specific WP user meta to the “EMAIL MARKETING” list field, the one that responds for Subscribe/Unsubscribe status.

    Basically, whenever a WP user changes a specific meta field to false, their status in MailChimp should changed to UNSUBSCRIBE.

    Is that possible to achieve ? Google didn’t provide any useful info ??

    Highly appreciate any help

    Regards,

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Lap

    (@lapzor)

    Please take a look at this snippet:

    https://github.com/ibericode/mc4wp-snippets/blob/master/add-ons/user-sync/sync-based-on-meta-field.php

    Hope that helps. If you have any questions, please let us know!

    Thread Starter cboom

    (@cboom)

    Hi Lap,

    Thank you for the quick response!

    I tried this thing and it works, but unfortunately it’s not the functionality I want.

    The above code will add to MailChimp only the users that have a specific meta_value, however I want to sync all users into MailChimp, but change their status to UNSUBSCRIBED if the specific meta_value is present.

    Any idea on how to do that ?

    I’ve tried the following code, but it doesn’t work ??

    add_filter( 'mailchimp_sync_user_data', function( $data, $user ) {
        $data['STATUS'] = $user->receiveInformation;             
        // receiveInformation has Subscribed/Unsubscribed values
    
        return $data;
    }, 10, 2 );
    Thread Starter cboom

    (@cboom)

    I am following up on this, as I still couldn’t make it work ??

    Lap, could you please have a look at my last comment ?

    To reiterate, I want on first sync the plugin to change the Subscribed/Unsubscribed field in MailChimp depending on whether a specific WP user meta is true or false.

    Would that be possible to achieve it ?

    Many thanks,

    Plugin Author Danny van Kooten

    (@dvankooten)

    Hi Cboom,

    The snippet that my colleague shared should actually do just that. It will not only send the users with that meta key to MailChimp but it will actively unsubscribe everyone without that meta key as well.

    The final snippet in your case would look something like this:

    
    /**
    * Only synchronise users with a meta field named "mailchimp_opted_in" with boolean value true
    */
    add_filter( 'mailchimp_sync_should_sync_user', function( $should, $user ) {
       return $should && (bool) $user->receiveInformation;	
    }, 10, 2 );
    
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Sync user meta to MailChimp “Email Marketing” field’ is closed to new replies.