How to get user metadata for social media url?

Use get_user_meta( $user->ID, ‘facebook’ , true ); But let me clarify you, none of the social media fields are WP core fields. You are using Yoast SEO, and these fields are Yoast SEO features. FYI: I see Yoast SEO from your screenshot. They are stored on the wp_usermeta table with the social media name in … Read more

How to get last login Access Date and time

Finally I found answer by myself. Let’s explore it with two user meta’s current_login, last_login.Lets see the code. //function for setting the last login function set_last_login($login) { $user = get_userdatabylogin($login); $curent_login_time = get_user_meta( $user->ID , ‘current_login’, true); //add or update the last login value for logged in user if(!empty($curent_login_time)){ update_usermeta( $user->ID, ‘last_login’, $curent_login_time ); update_usermeta( … Read more

remove user_meta data from database for all users

This is a super old post, for all you future readers, you can use the delete_metadata() function to achieve this with a lot less DB overhead: delete_metadata( ‘user’, // the meta type 0, // this doesn’t actually matter in this call ‘my_meta_key’, // the meta key to be removed everywhere ”, // this also doesn’t … Read more

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

wp_get_current_user always returns 0

wp_get_current_user() is actually just a wrapper for $current_user and get_currentuserinfo(), so you can use both. It’s important, though, to only call it on or after the init hook. Calling it before will only return 0, as you’ve experienced.

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

Capabilities Vs User Meta

There is no one answer, because both have pros and cons depending on what you want to store and why. A (probably non-exhaustive) list of differences to consider for a choice: Capabilities are designed to check if a user can do something or not. user_can and current_user_can are there to help you to check user … 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

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