How to save user meta on custom admin page

update_user_meta($current_user->ID, ‘description’, $_POST[‘user_description’]); in the form processing function will save the bio. I would keep the form action on the same admin page. As for data validation, I don’t see what there is to validate in the first place. It’s just a string – not an email, address or the like that needs to be … Read more

How to pull user/author profile data in a plugin?

If you’re trying to get user data for the displayed profile, you can do it like so: $thisauthor = get_userdata(intval($author)); That’ll return an object filled with everything you need. For instance, if you need the user ID, you can call it like so: $thisauthor->ID I use this extensively on the profiles on my site: http://androidandme.com/user/clark … Read more

Get user_meta values for a user for an array of meta_keys?

get_user_meta() with omitted key argument will return all data for the object. Trying to retrieve metadata selectively is usually pointless optimization from performance point of view, since everything built on Metadata API tends to just query all data anyway and cache it (which in turn object cache plugin makes persistent and snappy).

Randomize Users

I don’t see an “orderby Rand()” parameter for either get_users or WP_User_Query. There is a filter called pre_user_query that could be used but I am not sure I see the benefit of that when shuffle will randomize the array you already have. $args = array( ‘fields’ => ‘all_with_meta’, ‘exclude’ => array(1), ); $users = get_users( … Read more

The Simple and Correct Way to Add User Meta

Trying to detect when a UI was triggered, is indeed the wrong general approach (unless you want to tie to the UI). A proper one will be to hook on the user_register action. add_action( ‘user_register’, ‘wpse223196_registration_save’, 10, 1 ); function wpse223196_registration_save( $user_id ) { add_user_meta($user_id, ‘score’, 5); }

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)