How to update serialized data in the user meta data

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

Leave a Comment

tech