Comapare get_user_meta value

You can use meta_key or meta_query to fetch users where get_user_meta() ‘val’ == 1 Option 1: $users = get_users(array( ‘meta_key’ => ‘val’, // your_meta_key ‘meta_value’ => ‘1’, // value you want to compare ‘meta_compare’ => ‘=’, )); Option 2: $args = array( ‘meta_query’ =>array( array( ‘key’ => ‘val’, //your_meta_key ‘value’ => 1, // value of … Read more

Problems using ‘add_role’

You can pass the user’s role directly to wp_insert_user(). First, you can try to add your custom role to the WP_Roles object, then pass the custom role to the user properties: // Add custom roles only once to avoid unnecessary database calls. // It is usually done during plugin activation. register_activation_hook( __FILE__, ‘cyb_add_roles’ ); function … Read more

Front-End User Profile

UPDATE: As mentioned in the comments, you might want to learn how you do things like create meta boxes and do a file upload in WordPress without using a framework like CMB2 first. However, as a seasoned WordPress developer, I have found that using CMB2 greatly increased my productivity. I highly recommend using CMB2 to … Read more

Get the users that my following users are following

You can use the implode function to concatenate array elements: $get_the_following_users = get_user_meta($current_user->ID, ‘following_users’, true); $meta_qssuery = ”; //initialise to an empty string foreach ( $get_the_following_users as $following_user ) { $following_user = get_user_meta($following_user, ‘following_users’, true); if(!empty($following_user)) { //check if any data was returned $meta_qssuery .= implode(‘, ‘, $following_user).’, ‘; } } echo $meta_qssuery; This will … Read more

Copy usermeta value where ID matches in the same table

use this code, it may help you $users = get_users($args); if($users) { foreach($users as $user) { $user_id = $user->ID; $shipping_first_name = get_user_meta($user_id, ‘shipping_first_name’, true); if($shipping_first_name) { update_user_meta( $user_id, ‘first_name’, $shipping_first_name); } } } for $args – refer link https://codex.wordpress.org/Function_Reference/get_users

Adding Author Box Meta Links with Co-Authors

These are outside of the foreach loop: $twitter = get_the_author_meta(‘twitter’, $author_id); $facebook = get_the_author_meta(‘facebook’, $author_id); $googleplus = get_the_author_meta(‘googleplus’, $author_id); $linkedin = get_the_author_meta(‘linkedin’, $author_id); $instagram = get_the_author_meta(‘instagram’, $author_id); $youtube = get_the_author_meta(‘youtube’, $author_id); $email = get_the_author_meta(’email’, $author_id); So (remove that, and) try using $coauthor->ID with get_the_author_meta() like this: <div class=”author-box-social-icons”> <?php if( $email = get_the_author_meta( ’email’, $coauthor->ID … Read more