get_users is expecting unserialized meta_value

In your original code, you’re not passing an operator to meta_compare. Note that get_users() does not define a default operator. Try using ‘=’: $args = array( ‘meta_key’ => ‘custom-usermeta’, ‘meta_value’ => $cat_id, ‘meta_compare’ => ‘=’ ); $users = get_users( $args ); As a diagnostic, you might make sure that the problem isn’t the saving/querying by … Read more

Problem storing arrays with update_user_meta

Haven’t used the function for quite a time, but i guess your problem is that you are pushing an array into an array. So check if intval($_GET[‘auction’]) is an array: echo ‘<pre>’; print_r(intval($_GET[‘auction’])); echo ‘</pre>’; Edit #1: You maybe need to get the value from that array and then array_push it. So maybe something like … Read more

Return all users with a specific meta key

You can use the just the meta_key argument, the result will be similar to using the EXISTS sql statement. <?php $users = get_users(array( ‘meta_key’ => ‘your_meta_key’, )); Alternatively, you can use an empty string for meta_value (the default) and > for meta_compare. The result is the same (probably because meta_value gets ignored if its empty!). … Read more

wp_update_user doesn’t update and update_user_meta does

wp_update_user & metadata wp_update_user updates records in the *_users table. It isn’t meant to update custom metadata in the *_usermeta table. Hence your “problem” is actually expected behavior. The $userdata argument passed to wp_update_user can contain the following fields: ID, user_pass, user_login, user_nicename, user_url, user_email, display_name, nickname, first_name, last_name, description, rich_editing, user_registered, role, show_admin_bar_front Further … Read more

How to make a custom column on the Users admin screen sortable?

This is my code which adds a sortable custom column (called Vendor ID) to the users table: function fc_new_modify_user_table( $column ) { $column[‘vendor_id’] = ‘Vendor ID’; return $column; } add_filter( ‘manage_users_columns’, ‘fc_new_modify_user_table’ ); function fc_new_modify_user_table_row( $val, $column_name, $user_id ) { switch ($column_name) { case ‘vendor_id’ : return get_the_author_meta( ‘vendor_id’, $user_id ); default: } return $val; … Read more

add_user_meta() vs update_user_meta()

You have already found out that using update_user_meta() if the meta field for the user does not exist, it will be added. ie update_user_meta() can do the task of add_user_meta() However, the difference between them is the return values update_user_meta() returns False if no change was made (if the new value was the same as … Read more