Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

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.