By user608329


2011-09-02 00:02:20 8 Comments

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 comments

@goldenapples 2011-09-02 01:12:30

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

Related Questions

Sponsored Content

2 Answered Questions

Update user meta of author when post content is viewed

1 Answered Questions

[SOLVED] Wordpress REST API and User meta data

1 Answered Questions

Custom SQL query on wp_users with the addition of wp_usermeta

  • 2019-04-08 14:57:26
  • mcmaster.1986
  • 111 View
  • 1 Score
  • 1 Answer
  • Tags:   search user-meta

1 Answered Questions

[SOLVED] Increment user meta data by 1 each time a page is visited

1 Answered Questions

Update user meta via ajax from frontend, saving issue

1 Answered Questions

Getting user's data, by custom field lookup (meta)

2 Answered Questions

Sponsored Content