How to query users who have empty first_name?

It looks like you’re searching for the first_name meta keys with empty string meta values: $options = array( ‘meta_query’ => array( array( ‘key’ => ‘first_name’, ‘value’ => ”, ‘compare’ => ‘=’, ), ) ); $users = get_users( $options ); that generates this kind of SQL query: SELECT wp_users.* FROM wp_users INNER JOIN wp_usermeta ON ( … Read more

How to customize user search

I was able to find a solution: if(!empty($search)){ $query = $wpdb->prepare( “SELECT DISTINCT user_id FROM wp_usermeta WHERE meta_key = ‘pie_address_3’ AND meta_value LIKE %s “, ‘%’ . $search . ‘%’ ); $ids = $wpdb->get_results($query); ?> <ul class=”author-list”> <?php foreach ($ids as $id) { ?> <li> <img width=”90″ height=”90″ src=”https://wordpress.stackexchange.com/questions/182955/<?php echo get_user_meta($id->user_id,”pie_profile_pic_5″, true); ?>” class=”attachment-agent-image wp-post-image”> … Read more

Query Users by login, meta & role

It’s not entirely your fault The class responsible for generating the list of users does not honor the pre_user_query filter. This means that any custom column-sorting or filtering that relies on a modified (in pre_user_query) WP_User_Query object will not work. You can see what I mean in the patch below. Admin-user-list-table ignores the filter @@ … Read more

User Relationship

if I were you, I would use the wp_usermeta table. it is possible to add information to this table easily: add_user_meta(NEW_USER_ID, “PARENT_USER_ID”,USER_ID,true); USER_ID: the Id of top level user, (In your case id of user A) “PARENT_USER_ID”: some key that you could search and find result based on NEW_USER_ID: The Id of sub_user true: To … Read more

how to create a proper query for getting a list of users with taxonomy related meta key

Objective I want to list sp_provider (hospital,clinics,doctors) whose sub_category is suppose ‘neurology’ rephrasing the words: I want to list users with sp provider category(meta value) such as “hospital” and the user have a sub category(meta value) “neurology” sp_provider is a meta value in user profile (sp-provider maybe a post-type or something for user management screen … Read more

Echo the number of users using WP_User_Query?

We have the public properties: WP_Query->found_posts WP_Comment_Query->found_comments WP_Network_Query->found_networks WP_Site_Query->found_sites but then comes this private property (that’s also made public via magic getter): WP_User_Query::$total_users but not found_users as expected, so the confusion is natural 🙂 Look into the public get_total() method and the count_total bool attribute (true by default) in the docs.

How to use search_columns in WP_User_Query?

This is covered in the link you reference: The search_columns attribute does not set what should be searched for in each column, but instead specifies which columns should be searched for the term set in ‘search’. Specifically, you can only search for one term – but you can look in one or more columns. //Search … Read more

Users instead of posts: How to modify the main query?

Custom GET pagination parameter We can use a custom GET pagination parameter, e.g. upage or probably more unique as wpse-user-page, to use with your WP_User_Query. That way you avoid affecting e.g. the main post query. Generate pagination links with pageinate_links() We can use paginate_links() to generate the pagination: $args = array( ‘base’ => ‘%_%’, ‘format’ … Read more

WP_User_Query order by meta_key that is an array

You could save the values with the separate user meta keys: x1, …, x6, points instead of the array: achievements to simplify your WP_User_Query() usage and not having to deal with serialized arrays as user meta values. But I guess you’ve already considered this setup and wanted to avoid it 😉 A compromise would be … Read more

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