latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Mailchimp integration, custom merge fields

Home Forums Community Forum Mailchimp integration, custom merge fields

Tagged: 

This topic contains 7 replies, has 3 voices. Last updated by  Cristián Lávaque 4 years, 1 month ago.

Topic Author Topic
Posted: Friday Nov 16th, 2012 at 10:36 am #31777
Alex Read
Username: lab41

Hi, I’m using a silent subscription hack to silently subscribe some users to Mailchimp on registration. I’m also using a merge array filter to pass on custom fields (such as birthday and other details) to mailchimp – http://www.primothemes.com/forums/viewtopic.php?p=20994#p20994 .
I’m having trouble retrieving the custom s2member registration fields. Here is my s2-hacks.php code:

add_filter("ws_plugin__s2member_mailchimp_double_optin", "__return_false");
add_filter('ws_plugin__s2member_mailchimp_merge_array', 'mailchimp_merge', 10, 2);
function mailchimp_merge($merge, $vars)
    {
// $merge /* Array of existing MERGE fields that s2Member passes by default. */
// $vars /* Array of defined variables in the scope/context of this Filter. */

        //print_r($vars); // Lots of good stuff in this array.
		$user_id = $vars['user_id'];
		$cfields = get_user_option('wp_s2member_custom_fields', $user_id);
		

	return array_merge($merge, array('USER_ID' => $user_id, 'MERGE3' => $cfields['province'], 'MERGE4' => $cfields['two'], 'MERGE5' => date("m/d/Y")));

    }

Looking at mailchimp log, MERGE3 and MERGE4 come through as null.
Thanks,

  • This topic was modified 4 years, 1 month ago by  Alex Read.
  • This topic was modified 4 years, 1 month ago by  Alex Read.

List Of Topic Replies

Viewing 7 replies - 1 through 7 (of 7 total)
Author Replies
Author Replies
Posted: Friday Nov 16th, 2012 at 7:15 pm #31842
Raam Dev
Username: Raam
Staff Member

If they’re coming through as null, I recommend double-checking that province and two are actually the names of the Custom Registration Fields. Could it also be that someone left those fields empty when they submitted the form?

Posted: Saturday Nov 17th, 2012 at 4:40 am #31867
Alex Read
Username: lab41

If they’re coming through as null, I recommend double-checking that province and two are actually the names of the Custom Registration Fields.

Could it also be that someone left those fields empty when they submitted the form?

Don’t think so, it’s me filling it out.

Any ideas?

Posted: Sunday Nov 18th, 2012 at 7:44 am #31918

if you [hilite code]print_r($cfields)[/hilite], are [hilite mono]province[/hilite] and [hilite mono]two[/hilite] there?

Posted: Sunday Nov 18th, 2012 at 11:31 am #31932
Alex Read
Username: lab41

Hi where do I check the output of print_r? Thanks

Posted: Monday Nov 19th, 2012 at 8:26 am #31970

It’d be shown in the browser… but if you don’t see it there, then you could save it to a file and look there. http://stackoverflow.com/questions/2628798/print-array-to-a-file

Posted: Monday Nov 19th, 2012 at 11:56 am #31990
Alex Read
Username: lab41

Hi, thanks for the help. Had to change the get_user_option line by replacing

$cfields = get_user_option('wp_s2member_custom_fields', $user_id);

with

$cfields = get_user_option('wpsal_s2member_custom_fields', $user_id);

The “sal” I added on is specific to our site. Now it works fine :-)

Posted: Tuesday Nov 20th, 2012 at 7:56 am #32078

Ah, got it. Glad you found the problem! Thanks for the update. :)

Viewing 7 replies - 1 through 7 (of 7 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.