MailChimp Integration & Ultimate Facebook Solution for Merging Registration Data

This might be very helpful for anyone looking to merge registration data from Facebook Connect with MailChimp Integration; giving you the ability to use data within $registration and $me as additional merge fields.

I'm currently running Ultimate Facebook 2.6.6 and MailChimp Integration 1.3 on WordPress 3.8.1.

The problem which lead me to look for a solution was that when a new user tried to register on my site using Ultimate Facebook plugin, they would receive this error message, "Warning: MailChimp listSubscribe() Error: 250 - FNAME must be provided - Please enter a value in.." I noticed both the first name (FNAME) and last name (LNAME) fields were not being imported into MailChimp as it should.

The get_user_meta() and get_userdata() was not passing data for first_name and last_name or user_firstname and user_lastname.

With the Ultimate Facebook plugin disabled, everything works fine.

There must be a conflict between the two plugins, however I was able to hack the core to formulate a solution.

Simply hook into 'mailchimp_merge_vars' filter to provide any additional merge fields you want. This is an existing filter hook built into the plugin.

/* Add Custom Fields to MailChimp Registration */
function add_mailchimp_fields ($merge_vars, $user, $registration, $me) {
	$merge_vars = array(
		 "FNAME" => $me['first_name'],
		 "LNAME" => $me['last_name']
	return $merge_vars;
add_filter('mailchimp_merge_vars', 'add_mailchimp_fields', 10, 4);

However, if you noticed, there two additional arguments ($registration, $me) which we must hack the core plugin for the existing hook to work properly.

The modifications to the core plugin file (mailchimp-sync.php). You can view the entire source code here

I added an action hook:

add_action('wdfb-user_registered-postprocess', 'mailchimp_add_user', 10, 3); //for ultimate facebook

I commented out the following action hooks:

#add_action('wpmu_new_user', 'mailchimp_add_user');
#add_action('user_register', 'mailchimp_add_user');
#add_action('make_ham_user', 'mailchimp_add_user');

I added $registration and $me arguments to both the mailchimp_add_user() and mailchimp_edit_user() functions, as well as both apply_filters() for $merge_vars within those functions.

NOTE: These modifications only work if you have Ultimate Facebook plugin enabled, as we have removed various registration hooks and left only the hook which is executed when a user registers through Ultimate Facebook. Although, it would be possible to code the plugin with a bit of logic to determine which hooks need to be executed so there is no conflict. If we simply add the new hook and not comment out the hooks mentioned above, there are missing argument errors and double function execution during registration.

It would be nice to have the ability to pull data from the Ultimate Facebook registration fields like we find in this solution without having to hack the core plugin every time there is an update :slight_smile:


  • Thomas

    Hi Ignacio,

    You're brilliant! The new version now integrates perfectly with Ultimate Facebook. I made a few more modifications :slight_smile:

    I added two lines of code to add functionality for accessing all the variables during registration to be used as additional merge fields.

    Standard process for adding custom fields to registration:

    /* Add Custom Fields to FB Registration  */
    function add_registration_fields ($fields) {
    	$fields[] = array(
    		"name" => "ref_id",
    		"description" => "Referral ID",
    		"type" => "text",
    	return $fields;
    add_filter('wdfb-registration_fields_array', 'add_registration_fields');

    Standard process for adding custom merge fields:

    /* Add Custom Fields to MailChimp Registration */
    function add_mailchimp_fields ($merge_vars, $user) {
    	//$registration = $user->wdfb->registration;
    	$me = $user->wdfb->me;
    	$merge_vars['REFID'] = $me["ref_id"];
    	return $merge_vars;
    add_filter('mailchimp_merge_vars', 'add_mailchimp_fields', 10, 2);

    In order to populate $user with the registration data, we have to add the following lines of code to both integration.php and mailchimp-sync.php.

    integration.php (line 25)

    'wdfb' => (object) array( 'registration' => $registration, 'me' => $me )

    mailchimp-sync.php (line 122)

    $user->wdfb = (object) $uid['wdfb'];

    Would be pretty nice if this functionality were added in the next release. Thanks for all your help!

  • Thomas

    Here are some of the possible default facebook registration variables which can be used as merge fields within mailchimp:

    $registration = $user->wdfb->registration;


    $me = $user->wdfb->me;



  • Vinod Dalvi

    Hi @Thomas,

    Thanks for posting on the forum.

    Ideally its not a good process to post on a thread 3 months old. The plugin has changed since then and so has WordPress :slight_smile:

    To help keep support tickets separate, always open a new thread for your new question. This helps to prevent any confusion (for us) as I'm sure you understand.

    This might also help other members looking for a similar answer. :slight_smile:

    Thank you for being a WPMU DEV member and have a great day!

    Vinod Dalvi

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.