Custom Profile fields and Mailchimp

This is an URGENT CRITICAL issue and a quick response would be appreciated:

My registration/ profile has additional fields, one field is a Select Menu (multi-option) - However, the data selected in this field is not recorded on Mailchimp.

Please suggest a solution!
Thank you for your assistance.

Hi Brian.

You need a customization to have the custom profile fields added to your MailChimp as merge fields. This article should help get you started: http://web.archive.org/web/20190216055223/https://s2member.com/kb-article/can-i-add-custom-mail-merge-fields/

See also these to get the custom fields in your code:

https://www.s2member.com/codex/stable/s2member/api_functions/package-functions/#src_doc_get_s2member_custom_fields()

https://www.s2member.com/codex/stable/s2member/api_functions/package-functions/#src_doc_get_user_field()

I hope that helps. :slight_smile:

Hi

On a related matter, we have an additional field type ‘Select Menu (multi-option)’ but the users selections are not showing up in the users profile.

Hmm… Could you show me a screenshot of your field’s configuration, and tell me step-by-step how to reproduce the problem? I’ll try it with my installation to see if I can reproduce it.

Thanks. :slight_smile:

Hi Cristián,

Please see the images attached.

Screen%20shots|350x500
Thanks
B

Thanks for the screenshots.

It’s not very clear if all fields are selected, or none. In any case, it seems to be wrong.

I did several tests in my installation, and was able to create users with a multiple selection field just fine. Tried the wp-login and pro-form registrations, as well as the profile editor.

I did notice that a captcha plugin seemed to give some trouble in a test, so I removed it.

I believe you may be having some plugin conflict in your installation, something may be affecting the normal behavior of the profile fields.

Could you please test deactivating other plugins/theme, and creating new users, to see if the behavior is the same?

:slight_smile:

Hi

I think I´m missing something here! I have added a new file /wp-content/mu-plugins/s2-hacks.php
and added the code below (the mergetags are correct) but still no data is being passed to mailchimp.

<?php
add_filter('ws_plugin__s2member_mailchimp_merge_array', function ($custom_fields, $vars)
{
    $args = &$vars['args']; // stdClass object.
    # print_r($args); // for a full list of all properties.

    $custom_fields = array_merge($custom_fields, array(
        'ID'       => $args->id,
        'ROLE'     => $args->role,
        'REGDATE'  => $args->registration_date,
        'ORGAN'    => $args->organisation,
        'COMPROLE' => $args->Company_role,
        'COUNTRY'  => $args->country,
        'INTEREST' => $args->interest,
        'PRIVACY'  => $args->privacy_policy,

        // A Custom Registration/Profile Field in s2Member can be obtained like this.
        // Note that `my_custom_field_id` should be replaced with the Unique ID that you configured for a field in s2Member.
        // 'MY_CUSTOM_FIELD' => get_user_field('my_custom_field_id', $args->user_id),
    ));
    return $custom_fields;

    // Note that custom fields (aka: merge tags) will NOT work unless & until they are created by
    // a site owner working inside their MailChimp account. They must first add the custom fields
    // so they can be filled by the s2Member filter seen here.

    // See: <http://kb.mailchimp.com/merge-tags/using/getting-started-with-merge-tags>
}, 10, 2);

Please advise
Thank you

Did you print_r($args) to get the exact keys you have available? You’re using “id” instead of “user_id”.

Also, you’re trying to add your custom profile field with $args->interest, but right below the comment explains that you should get_user_field('interest', $args->user_id)

       // A Custom Registration/Profile Field in s2Member can be obtained like this.
       // Note that `my_custom_field_id` should be replaced with the Unique ID that you configured for a field in s2Member.
       // 'MY_CUSTOM_FIELD' => get_user_field('my_custom_field_id', $args->user_id),

The keys have to match, and they’re case-sensitive too. So make sure you don’t write “Company_role” if the field’s id is “company_role”.

Also important:

    // Note that custom fields (aka: merge tags) will NOT work unless & until they are created by
    // a site owner working inside their MailChimp account. They must first add the custom fields
    // so they can be filled by the s2Member filter seen here.

Also, enable logging, and if after your test you didn’t get it to work, check the MailChimp log to see what it says about it. WP Admin > s2Member > Log Files

I hope that helps. :slight_smile: