How to include first and last name in Mailchimp integration

I capture First and Last names (plus email address) during the registration process using Protected Content plugin. When using the Mail Chimp integration plugin, it is only uploading the email address. How do I include the First and Last names?

I checked the plugin and add-on files. I'm no programmer, but this is what I found:

In the plugin /app/view/shortcode/class-ms-view-shortcode-registeruser.php

line 110:
'first_name' => array(
'id' => 'first_name',
'title' => __( 'First Name', MS_TEXT_DOMAIN ),
'type' => MS_Helper_Html::INPUT_TYPE_TEXT,
'value' => $data['first_name'],
),

'last_name' => array(
'id' => 'last_name',
'title' => __( 'Last Name', MS_TEXT_DOMAIN ),
'type' => MS_Helper_Html::INPUT_TYPE_TEXT,
'value' => $data['last_name'],
),
In the add-on /mailchimp/class-ms-addon-mailchimp.php

line 381:
$merge_vars = array();
if ( ! empty( $member->first_name ) ) {
$merge_vars['FNAME'] = $member->first_name;
}

if ( ! empty( $member->last_name ) ) {
$merge_vars['LNAME'] = $member->last_name;
}

I checked the MailChimp list and their field columns are "First Name" and "Last Name" though their merge tags are FNAME and LNAME.

Are the titles missing from the add-on script? Or some merge tag conflict? It just doesn't seem like MailChimp is recognizing the name values being thrown at it.

thanks
j

  • Vinod Dalvi

    Hi Jennifer,

    I hope you are well today and thank you for your question.

    In the file add-on /mailchimp/class-ms-addon-mailchimp.php could you please temporary change the code as following and let me know what you are getting as output when the user subscribes so that i can troubleshoot the issue?

    Before Editing:

    $merge_vars = array();
    if ( ! empty( $member->first_name ) ) {
    	$merge_vars['FNAME'] = $member->first_name;
    }
    
    if ( ! empty( $member->last_name ) ) {
    	$merge_vars['LNAME'] = $member->last_name;
    }

    After Editing:

    print-r($member);
    $merge_vars = array();
    if ( ! empty( $member->first_name ) ) {
    	$merge_vars['FNAME'] = $member->first_name;
    }
    
    if ( ! empty( $member->last_name ) ) {
    	$merge_vars['LNAME'] = $member->last_name;
    }

    Kind Regards,
    Vinod Dalvi

  • Philipp Stracker

    Hi Jennifer,

    so finally we've released a big maintenance/bug fix update some days ago that includes a reviewed Mailchimp add-on. It's all working as expected now, including correct transfer of the members firstname and lastname. So please update to 1.1.1.4

    Just FYI - you were already on the right track with the code you posted in the top!

    In the add-on /mailchimp/class-ms-addon-mailchimp.php

    // This was the problem due to use of magic methods by $member:
    if ( ! empty( $member->first_name ) ) {
    
    // In this case the condition should look like this to work:
    $first_name = $member->first_name;
    if ( ! empty( $first_name ) ) {

    Let us know if there's anything else we can help you with!

    Thanks, Philipp :slight_smile:

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.