|
Hi Andrew.
Have you created the “BUDGET” and “WTGOAL” merge fields in MailChimp?
|
|
These fields exist in mailchimp.
|
|
Got it.
Just to check if the arrays are what they’re supposed to be, after the line
[hilite pre_code]
$my_custom_merge_vars = array("BUDGET" => $budget, "WTGOAL" => $wtgoal);
[/hilite]
could you add these as a test?
[hilite pre_code]
echo '<'.'pre>';
print_r($my_custom_merge_vars);
print_r($merge);
echo '
';
[/hilite]
*Had to split the pre tag cause it was getting parsed here in the post :P
|
|
I added that and registered on the site but I’m not seeing where this information should be printed.
|
|
Hmm… I think I see what the problem is with the hack. It’s missing the priority and number of arguments in the [hilite mono]add_filter[/hilite] function call. http://codex.wordpress.org/Function_Reference/add_filter
Try this, please:
[hilite pre_code]
$budget, 'WTGOAL' => $wtgoal));
}
?>
[/hilite]
|
|
Dang, just updated it with the code above and still nothing.
|
|
Hmm… I think [hilite mono]get_user_field[/hilite] is being used wrongly, cause it doesn’t have access to the specific fields like that, you have to get the whole array of custom fields getting [hilite mono]s2member_custom_fields[/hilite].
How about this?
[hilite pre_code]
$cfields['budget'], 'WTGOAL' => $cfields['wtgoal']));
}
?>
[/hilite]
|
|
Success!
It worked.
Do you know why it wasn’t working previously? Was the original code sample I used from an older version of the plugin? I’m just trying to learn more about how the plugin is built so I can continue to bolt on the features I need.
|
|
Only somewhat related to this but i like what i see. I wonder if this kind of coding could be used to automatically fill merge tags in MC with the date of registration/purchase of a certain product (based on ccaps)? If so (and if it is not already included in the next major release) i might look into that.
-
This reply was modified 4 years, 9 months ago by
cassel.
|
|
Success!
It worked.
Do you know why it wasn’t working previously? Was the original code sample I used from an older version of the plugin? I’m just trying to learn more about how the plugin is built so I can continue to bolt on the features I need.
Great! :)
Right, seems to have been an outdated script. I guess the function changed since then, I just noticed the mistake yesterday when I reviewed its documentation again after a long time.
Only somewhat related to this but i like what i see. I wonder if this kind of coding could be used to automatically fill merge tags in MC with the date of registration/purchase of a certain product (based on ccaps)? If so (and if it is not already included in the next major release) i might look into that.
Yes, you can adapt the hack to store other values, like registration dates.
[hilite path]Dashboard -› s2Member® -› API / Scripting -› Content Dripping[/hilite]
http://www.s2member.com/codex/stable/s2member/api_functions/package-functions/#src_doc_get_user_field%28%29
|
|
Perfect, thanks so much for the help!
|
|
Yes, you can adapt the hack to store other values, like registration dates.
Dashboard -› s2Member® -› API / Scripting -› Content Dripping
http://www.s2member.com/codex/stable/s2member/api_functions/package-functions/#src_doc_get_user_field%28%29
Any info whether it is included in the next release before i get into coding?
|
|
Perfect, thanks so much for the help!
You’re welcome! I’m glad I could help you. :)
Any info whether it is included in the next release before i get into coding?
Heh, there’s a good chance. There will be a big improvement for this, but I’m not sure if it’ll include payment times, so you may still need to use a hack.
Anyway, this hack is quite simple, so it won’t take you too long to implement now, or update later. ;)
|
|
Heh, there’s a good chance. There will be a big improvement for this, but I’m not sure if it’ll include payment times, so you may still need to use a hack.
Anyway, this hack is quite simple, so it won’t take you too long to implement now, or update later. ;)
Great to know. I might just get to learn more coding, even if just for the “fun” of it! :)
Thanks Andrew for the code!
|
|
|
|
As an add-on to this question, can you help me, here’s what I’m trying to do.
1) user registers for the site by replicating the signup form
2) user details are sent to mailchimp (as completed in the above function)
3) i then take the user to a survey where they have to fill out 5-6 additional questions
4) user submits their information, its stored in s2member_custom_fields
5) the information is then sent to mailchimp to sync
— Basically I just need to be able to run the mailchimp_merge_array through some sort of PHP call so I can sync the data in the wordpress database with what Mailchimp has
|
|
You may want to try using this method, which is the one that does the job during registration, only you’d call it at some other time: [hilite mono]c_ws_plugin__s2member_list_servers::process_list_servers[/hilite]
http://www.s2member.com/codex/stable/s2member/list_servers/c_ws_plugin__s2member_list_servers/#src_doc_process_list_servers%28%29
|
|
Cristian, can you explain how to use this function?
Here is what I have
// get the user fields and then update them with the data sent to this page
$custom_fields = get_user_option("s2member_custom_fields");
$custom_fields = array(
'AGE' => $age,
'BUDGET' => $budget,
'WTGOAL' => $wtgoal,
'HEALTH' => $health,
'BODY' => $body,
'MEALTYPE' => $mealtype,
'EXERCISE' => $exercise,
'GENDER' => $gender,
'FIRST_NAME' => $first_name
);
update_user_option($user_id, 's2member_custom_fields', $custom_fields);
// update this user based on their email and userid
process_list_servers($email, $user_id);
and then in s2-hacks.php i have this
<?php
add_filter('ws_plugin__s2member_mailchimp_merge_array', 'mailchimp_merge', 10, 2);
function mailchimp_merge($merge, $vars)
{
$cfields = get_user_option('wp_s2member_custom_fields', $vars['user_id']);
return array_merge($merge, array('BUDGET' => $cfields['budget'], 'WTGOAL' => $cfields['wtgoal'], 'AGE' => $cfields['age'], 'HEALTH' => $cfields['health_conditions'], 'BODY' => $cfields['body'], 'MEALTYPE' => $cfields['meal_type'], 'EXERCISE' => $cfields['exercise'], 'GENDER' => $cfields['gender'], 'FNAME' => $cfields['first_name']));
}
?>
When I check for the user details in Mailchimp its not updating the.m
-
This reply was modified 4 years, 9 months ago by
andrew wise.
|
|
Sorry, I can’t help with that. :/
s2Member® » Support Policy » Fine Lines
If you need a developer’s help, you could find good freelancers in sites like oDesk.com, eLance.com or jobs.wordpress.net.
I hope that helps. :)
|
|
Cristian, thanks for the help well I guess my question is for this function to work properly can you show me an example request?
When I ran it above, I only had 2 parameters included, but I’m assuming I need to have all of the parameters included to have this function initiate itself?
|
|
[hilite pre_code]
$cfields = get_user_option('wp_s2member_custom_fields', $vars['user_id']);
[/hilite]
will give you all the custom fields that have a value for the user, not just budget and wtgoal. You can add more of those to the array to be merged. Is that what you meant?
|
|
Can you show me how to use this function?
process_list_servers($email, $user_id);
i’ve got everything filled out except the password, but its not working, so i must be missing something
process_list_servers('subscriber', '0', $login, '', $email, $first_name, '', $ip, 'true', 'false', $user_id);
|
|
I asked Jason about using [hilite mono]c_ws_plugin__s2member_list_servers::process_list_servers[/hilite] and if all arguments were required to make it work, including password. Here’s his reply:
Yes, a site owner could certainly use this through a hack if they like.
All arguments are required, but you’re right, the plain text password is nearly impossible. That can be spoofed with something like “xxx”, just so it has a value. s2Member only passes that along to AWeber in a few special cases, and it’s NOT anything real important. I’ts fine 99.9% of the time to just spoof that.
If a site owner uses this hack…
[hilite pre_code]
[/hilite]
Only then will s2Member actually need the plain text password. In all other cases, just spoof it with the encrypted version, or just use “xxx”.
|
|
Thanks for the help, I think I’m almost there.
To run this function, do I have to add in a filter? I’m trying to just call it on a random page on my site, but its throwing an error (which i cant see because my shared server does not show php erros).
Here is what I’m calling, and all variables have content.
process_list_servers('subscriber', '0', $login, 'xxx', $email, $first_name, 'xxx', $ip, 'true', 'false', $user_id);
|
|
|