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

Update user meta using with ajax

Alright, there’s a few things that isn’t standardized WordPress so I’ve put together a minimal script which I’ll explain piece by piece. Hopefully clear things up for you by the time you get to the end. HTML Form Below is a very simple HTML form. We’re going to use javascript to listen for submission and … Read more

get posts based on meta value of the author

Get for all users / authors with user meta field. meta1 = true $args = array( ‘meta_key’ => ‘meta1’, ‘meta_value’ => ‘true’, ‘meta_compare’ => ‘=’, ‘fields’ => ‘all’, ); $users = get_users( $args ); Store user id and login into an array authors $authors = array(); foreach ( (array) $users as $user ) { authors[ … Read more

How to get users by a custom field / by user meta data?

What is the exact meta_key and meta_value for the field I created using the function custom_user_profile_fields ? created_by and some user ID, for example: $args = array( ‘meta_key’ => ‘created_by’, ‘meta_value’ => 123, ) You could use a meta_query for more complex searches. $args = array( ‘meta_query’ => array( array( ‘key’ => ‘created_by’, ‘compare’ => … Read more

Save custom user meta on registration

You have to trigger the following hooks: user_register personal_options_update edit_user_profile_update add_action(‘user_register’, ‘addMyCustomMeta’); add_action(‘personal_options_update’, ‘addMyCustomMeta’ ); add_action(‘edit_user_profile_update’,’addMyCustomMeta’ ); function addMyCustomMeta( $user_id ) { update_user_meta( $user_id, ‘user_phone’, $_POST[‘user_phone’] ); } Hope that helps!!

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

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