Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Harish Chouhan

    (@hchouhan)

    Hello meglos42,

    Currently the only option is to sync all users or to choose what user role you wish to subscribe. If you set non-active users in a different role and convert them to “Subscriber” role after account activation then you would be able to sync only the active users by choosing “Subscribers” as the role to sync.

    I hope I have answered your query, if not please do let me know.

    Thread Starter meglos42

    (@meglos42)

    Hi Harish,

    Not really I’m afraid. I’m using 3 user roles and wish to sync all of them with the mailchimp list, so limiting sync to only “Subscribers” isn’t an option for me.
    Also when new users register for access to the protected areas of the site their login requests are moderated and it’s important that they don’t get any newsletters before they have been activated.

    Thanks.

    Plugin Author Harish Chouhan

    (@hchouhan)

    Hey meglos42,

    While there is no direct way of doing that I would discuss this with my colleagues to see if there are any way to do this. Please do allow us a few days to get back.

    Thread Starter meglos42

    (@meglos42)

    Hi Harish,

    Have you come up with a solution at all?

    Another option – I have created a custom role with no site access and set that to the default new member role.

    Is there (or could there be built) an option to synchronise several selected roles only (not just one), so I can exclude this custom role but include Admin and Author roles?

    Thanks

    Plugin Author Harish Chouhan

    (@hchouhan)

    Hi,

    Danny my colleague has just got back to work, so he should be able to get look into this and get back to you by next week.

    Plugin Author Danny van Kooten

    (@dvankooten)

    Hi @meglos42,

    How are you handling inactive users? Is that functionality added by a plugin or maybe some core WordPress functionality I don’t know about yet?

    I hope to release an update of MailChimp Sync this week that at least lets you control whether a certain user should be subscribed using a filter, so you can add some code to your theme its functions.php file and use whatever criteria you like. That said, knowing the details of your use case would be immensely helpful in making such things easier. ??

    Thanks in advance!

    Thread Starter meglos42

    (@meglos42)

    Hi Danny,

    I’m using the ‘WP Members’ plugin to moderate user accounts. A lot of the site is restricted and accessible only by logged-in users (99% of the user accounts are Subscribers).

    By default site registrations are open, but a user is inactive (via an “active” field in the usermeta table) until activated by an administrator. Only then can they access the protected content.
    I’d like to ensure that these pending users don’t get any emails until they have been confirmed and activated.

    Hope this helps ??

    Plugin Author Danny van Kooten

    (@dvankooten)

    Hey @meglos42, that definitely helps! We’ll push out an update of the plugin this week after which I’ll get back to this topic with a code example for you to use.

    Plugin Author Danny van Kooten

    (@dvankooten)

    Hey meglos42,

    We’ve just pushed out version 1.0.2 of the plugin which includes a filter called mailchimp_sync_should_sync_user that lets you set your own criteria to decide whether a user should be subscribed.

    The following code should help you get started.

    add_filter( 'mailchimp_sync_should_sync_user', 'myprefix_sync_criteria', 10, 2 );
    
    function myprefix_sync_criteria( $sync, $user ) {
    
        // make sure user has meta data named "active"
        $active = get_user_meta( $user->ID, 'active', true );
    
        // you might want to make the next line more strict
        // depending on what the value of the user_meta is..
        if( ! $active ) {
          $sync = false;
        }
    
        return $sync;
    }

    Does that help?

    Thread Starter meglos42

    (@meglos42)

    Hi Danny,

    Hopefully so, I’lll test over the next day or two. Thanks for your time & effort working on this.
    Just to clarify, WP-Members adds a new lines (1 per user) to the metadata table with the following field values –
    umeta_id = xxx
    user_id = yyy
    meta_key = ‘active’
    meta_value = ‘0’ or ‘1’ (depending on whether the user is active or not)

    Not sure if this affects the way the function needs to be constructed?

    Thread Starter meglos42

    (@meglos42)

    Hi Danny,

    That works perfectly!
    Many thanks once again.

    Thread Starter meglos42

    (@meglos42)

    Hi again Danny,

    Looks like I spoke too soon.

    The plugin/function doesn’t sync inactive users when I “synchronise all”, which is great.
    However when it’s listening to changes it doesn’t seem to pick up a change in the “active” state from “1” to “0” or vice versa, which means that new WordPress user registrations don’t get added to the Mailchimp list when they’re activated, nor do users get unsubscribed when they are deactivated.
    Deleting the user still unsubscribes them OK.

    Is there anything can be done to get this working?

    Thanks.

    mother.of.code

    (@imazed)

    The Mother of Code

    As meglos42 has opened a new topic on this, further replies can be read here.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Do not sync inactive users’ is closed to new replies.