Support » Plugin: MailChimp User Sync » Use new filters to create WP users from MailChimp subscribers

  • Resolved joshuaiz

    (@joshuaiz)


    In the latest version, you’ve added the filter mailchimp_sync_webhook_user. How can I use this to create WP users from my MailChimp list?

    A few people have asked about this functionality with the plugin…is this now possible?

    If we need to use a webhook, can you supply an example?

    In short, I have a list of a couple hundred subscribers on MailChimp that I need to import into my site as WordPress users. How do I do this?

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Danny van Kooten

    (@dvankooten)

    Hi Joshua,

    Yes, that is definitely possible now. Please make sure you’re on version 1.2.3 though, otherwise this will not work.

    Here are the steps you will need to take.

    1. Configure the webhook in MailChimp. Make sure to leave the bottom “via API” option unchecked.
    2. Add code based on this example to your site which creates the user if no user is found. Please make sure to generate a random password instead of the ‘password’ used in my example.

    Now, whenever a change occurs in your MailChimp list, your site will be notified of the change. If you have mapped WordPress user fields to MailChimp fields then these fields will be updated, along with the email address.

    Right now you will need to trigger a webhook request for all of your users, there might be a bulk way to do that inside MailChimp but I am not super sure about that. I’ll get to work on a way to import new users from a MailChimp export CSV as well.

    Hope that helps. If not, let me know!

    Follow up question for this. I have a ‘Password’ field in my MailChimp list to send out to my subscribers to log in for the first time. How can I modify the code from #2 to use this field for the user_pass in WordPress?

    For a little more info, this Password field is a duplicate of the EUID field as it is a unique identifier that I can include via merge tag to each user.

    I’m asking this question here before trying anything as I only want to import my MailChimp subscribers as users once 🙂

    Another question: how does WordPress handle the user_name field if there isn’t one with this kind of import?

    Hi Joshuaiz

    Did you manage to import your Mailchimp users into WordPress?
    Thanks
    Christine

    I am curious about this too, I don’t mind using the generate password script but am not 100% sure on what to do for that
    $user_id = wp_create_user( $data['email'], wp_generate_password(), $data['email'] );

    Would I add the random password like this?
    wp_generate_password(newpassword)

    Plugin Author Ibericode

    (@ibericode)

    Hi all,

    In case this is still needed (sorry about the late reply, we were swamped with work that pays the bills), the following modification of the code we sent earlier will use the “PWD” field from the given MailChimp list.

    add_filter( 'mailchimp_sync_webhook_user', function( $user, $data ) {
    	// have user already? use that.
    	if( $user instanceof \WP_User ) {
    		return $user;
    	}
    
    	// no user yet, let's create one.
            $password = $data['merges']['PWD'];
    	$user_id = wp_create_user( $data['email'], $password, $data['email'] );
    
    	// send notification to user
    	wp_new_user_notification( $user_id );
    
    	// return complete user object
    	return get_userdata( $user_id );
    }, 10, 2 );

    Hope that helps. If not, let me know!

    Hello,

    I’m also looking to create a new wordpress user once someone has signed up to the mailchimp mailing list. I’ve added the code and followed instructions above, but it didn’t create a user in WordPress.

    Please can you advise? Where should I add the “add_filter” code? I’ve added to my site’s functions.php at the moment?

    Cheers,
    Jonny

    Plugin Author Ibericode

    (@ibericode)

    Hi Johnny,

    Did you create the webhook in your MailChimp account and are you on the latest version of MailChimp Sync (with the settings page fully configured)?

    If so, does the debug log on MailChimp for WP > Other show anything?

    Your active theme its functions.php file is a suitable place for that add_filter code, yes!

    Latest version of MC Sync, I created the webhook too.

    I’m pretty certain the settings page is fully configured, and the debug log isn’t actually showing anything.

    Is it affected by what fields my mailchimp form is requesting? All I have is First Name, Last Name and Email Address

    Plugin Author Danny van Kooten

    (@dvankooten)

    Hi Johnny,

    Are these fields marked as required in your MailChimp list? If so, you should configure them in the “Send Additional Fields” setting on the MailChimp for WP > User Sync settings page.

    Using that setting you can specify which user fields to send to which MailChimp fields.

    Even then, the plugin should write an error message to the debug log in case MailChimp denies the sign-up request. It could be that the debug log file doesn’t have the proper file permissions, could you please check if /wp-content/uploads/mc4wp-debug.log exists and is writable?

    Hi there,

    Yeh, they are marked as required.

    I’ve made the log file writable now, but doesn’t seem to have updated annoyingly.

    This link shows a screenshot of my setup on the User Sync screen… have I done it all correctly? http://imgur.com/7TWFVPn

    Basically what I want is when someone uses the form to sign up to the list, it creates a new wordpress subscriber using the details they’ve added.

    Sorry if I’ve got the wrong end of the stick with this plugin!

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Use new filters to create WP users from MailChimp subscribers’ is closed to new replies.