Page 1 of 1

How do I update a s2member custom field in php?

PostPosted: September 1st, 2011, 6:33 pm
by bsowards
I'd like my template to read in a custom field, and update the number by one.

Here's my code

Code: Select all
$team_member = get_userdata(intval($team_member_id));
$team_member_donations_collected = $team_member->wp_s2member_custom_fields["donations_collected"];

$team_member_donations_collected_update = (int)$team_member_donations_collected + (int)$amount;

//this last line causes an error
update_usermeta( $team_member_id, wp_s2member_custom_fields["donations_collected"], $team_member_donations_collected_update );


How should I be updating this custom field with the new number?

Re: How do I update a s2member custom field in php?

PostPosted: September 1st, 2011, 6:49 pm
by bsowards
Ok I figured out that I need to use: http://codex.wordpress.org/Function_Ref ... _user_meta

But could anyone provide the syntax for this use case?

Re: How do I update a s2member custom field in php?

PostPosted: September 1st, 2011, 7:27 pm
by bsowards
OK so here we go, is there an update_user_field to compliment get_user_field?

viewtopic.php?f=40&t=12453&src_doc_v=110815#src_doc_get_user_field()

Re: How do I update a s2member custom field in php?

PostPosted: September 1st, 2011, 11:41 pm
by Cristián Lávaque
Try this and print_r it.

Code: Select all
$s2_custom_fields get_user_option('wp_s2member_custom_fields'$user_id);  


Then try editing the values and update_user_option. https://codex.wordpress.org/Function_Re ... ser_option

Let me know if it helps. :)