2

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?

1 Answer 1

7

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);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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