WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In my wp_usermeta table I have a field called "wp_s2member_custom_fields"

In it is stored this value:

a:2:{s:6:"alumni";s:3:"Yes";s:19:"donations_collected";s:2:"10";}

I am trying to use:

update_user_meta( $team_member_id, wp_s2member_custom_fields, $meta_value)

To update "donations_collected" from 10 to 11.

What should I put in $meta_value?

share|improve this question

Thats just PHP serialized array notation. You would get that same result by this code:

$meta_value = array(
    'alumni' => 'Yes',
    'donations_collected' => '10'
    );

update_user_meta( $team_member_id, 'wp_s2member_custom_fields', $meta_value);

So if you want to then change the donations_collected value to 11:

$meta_value = get_user_meta( $team_member_id, 'wp_s2member_custom_fields', true );    
$meta_value['donations_collected']++;
update_user_meta( $team_member_id, 'wp_s2member_custom_fields', $meta_value);
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.