WORDPRESS – UPDATE MEMBER META PROGRAMMATICALLY IN WISHLIST MEMBER PLUGIN
WishListMembers plugin is a great plugin for membership site no doubt, it brings lots of features in the table but one thing I disappointted though is the lack of user management where users or members are allowed to modify their info, level or custom form field, so I’ve decided to dig around in their codex area and fortunately I’ve found a light, and I want to share you this, you’re lucky folks you’re in the right place.
Without further ado lets get started
Get Member
Syntax
1 |
get_member( $user_id, $raw = false ); |
Parameters
1 2 3 4 |
{ $user_id, $raw = false } |
Before we can update member meta or in WishList it’s called user options, first we have to fetch member custom or default address fields.
For version 2.71.2026 and below
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
// initialize our APIMethods class $wlapi = new WLMAPIMethods(); $member_array = $wlapi->get_member( $user_id ); //var_dump( $user_metas ); if( $member_array ) { foreach( $member_array['member'] as $member ) { // assign UserInfo arrays into new variable for later use $user_info = $member['UserInfo']; // for default value such us, company, address1 and 2, city, state, zip and more $user_address = $user_info['wpm_useraddress']; // for custom user field or options, just simply add "custom_" followed by the custom field name // e.g. $custom_field = $user_info['custom_field_name']; } } |
For latest version you can just simply call wlmapi_get_member()
method without initiating API Method class.
Update Member
Syntax
1 |
update_member( $user_id, $args ); |
Parameters
1 2 3 4 |
{ $user_id, $args // array } |
Code
Below code assumed you already assigned posted or submitted data.
1 2 3 4 5 6 7 8 9 10 11 |
// initialize our APIMethods class $wlapi = new WLMAPIMethods(); $member_array = $wlapi->get_member( MEMBER_ID ); $args = array( 'custom_custom_field' => $custom_email, 'city' => $city, 'state' => $state, 'zip' => $zip ); $wlapi->update_member( $user_id, $args ); |