Questions tagged [wp-user-query]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
12
votes
2answers
24k views

How can I search for a worpress user by display name or a part of it?

I need to create a search page that will display anything related to the supplied search. i.e. comments containing it, events, posts, CPTs and users with that name. How can I search for users in ...
10
votes
3answers
13k views

How to display pagination links for WP_User_Query?

I think I'm nearly there with this, but I can't get the pagination links to show for a directory of authors I'm creating. My code is below, but I don't know how to get the links to navigate between ...
9
votes
3answers
3k views

WP_User_Query to exclude users with no posts

I see that it is possible to sort a user query by the number of posts each user has, but is it possible to exclude users with zero posts from the result? In the Wp_User_Query class there is a ...
7
votes
3answers
37k views

how to get list of all users and their metadata

How do I get a list of all users with role = 'Customers' including all the metadata per user, means wp_users + wp_usermeta. Query below does not generate the wanted results. $query = "SELECT * ...
7
votes
2answers
3k views

Query users by custom taxonomy and user role

I'm trying to make a query for users using WP_User_Query() I need to filter users by role shop_manager and custom taxonomy called shop-category and current taxonomy term ID. The code I have so far: &...
6
votes
3answers
10k views

List users by last name in WP_User_Query

How can I list users by last name ASC when using WP_User_Query? There is an orderby parameter but looking in core it doesn't accept ordering my user meta. Anyone know how to extend WP to allow this ...
6
votes
2answers
572 views

Single loop for wp_query and wp_user_query

First of all, I tried searching and working on this, but couldn't create the logic or method to do this. I'm trying to display users and custom post type content together into a single loop. I can ...
4
votes
2answers
4k views

Searching users with WP_List_Table plugin

I am trying to devlope a plugin that will search and return my users so I can edit some other metatdata that belongs to them. I have been using the plug-in listed on the Codex as my starting point. I ...
4
votes
1answer
746 views

WP_User_Query will not combine meta + normal search methods

I've been trying to run a search on user names by following the wordpress codex but it doesn't seem to work... The following query, which is copied directly from the codex, returns 0 results. However,...
4
votes
1answer
2k views

WP User Query with search columns and meta query

I'm trying to build a query with WP User Query where it's possible to search after user_email user_nicename first_name last_name This are my args: $args = array( 'role' => '...
4
votes
1answer
105 views

Want to add my custom prepare query but add_filter doesn't run

I want to manipulate the order of WP_User_Query(). I want the user to come out ordered by a custom meta field and by ascending order. I have the code correctly working tested it on users.php but ...
4
votes
1answer
499 views

Wp_User_Query not sorting by meta key

I'm trying to list users sorted by a meta value. I store a score for each user in their user meta which is just a number but the loop isn't sorting. I include the score in the loop so that I can see ...
3
votes
2answers
3k views

How to search display_name column when using WP_User_Query

I'm using WP_User_Query to bring back a list of users. According to this article, I can focus the query on particular columns (I'm assuming in the wp_users table) using the search_columns param. My ...
3
votes
1answer
2k views

How to add custom query filters in WP_User_Query

I am creating a list of all users in wordpress. For that I am using WP_User_Query with meta_query so that I can show only filtered users. I am stuck where I want to add a custom query filters in ...
3
votes
1answer
2k views

WP_User_Query users by registered date

I'm trying to get the number of user who registered today. I've tried this: $args = array ( 'role' => 'Subscriber', 'meta_query' => array( array( 'key' => '...
3
votes
1answer
7k views

Getting all user metadata from user

I am trying to show bio and other custom metadata for my users in a page. So, i want to query the user metadata table for it. I have tried but did not find any functions for that. What i am looking ...
3
votes
2answers
452 views

Check if WP_User_Query 'include' is empty

This is my code: $args = array ( 'order' => 'DESC', 'include' => get_user_meta($author->ID, 'the_following_users', true) ); $wp_user_query = new WP_User_Query( $args ); $...
3
votes
1answer
852 views

User appears twice in a WP_User_Query

For some reason during a user query with a meta filter I have a user who when I print_r the results appears twice in the list... I have checked the database, just in case there seemed to be duplicate ...
3
votes
2answers
340 views

What is the most efficient way to search users by their display name?

Initially I thought I'd use get_users() but it turned out it doesn't support the display_name field. Then I've read about using WP_User_Query, but when I do it always exhausts the allowed memory size ...
3
votes
2answers
213 views

Get Y random authors' ID/Object with more than X number of posts

I want to display Y number of authors' info randomly. These authors have to have at least X numbers of posts published. Please keep in mind that this would be for a blog with thousands of users where ...
3
votes
1answer
466 views

each_connected in wp_user_query with Scribu's Posts to Posts Plugin - Alternative method? [closed]

I have been using Scribu's Posts to Posts plugin for some time, and it has served me well. I have read the full wiki and issues list, but can't find any definitive answer if there is a clean way to ...
2
votes
2answers
869 views

How to order WP_User_Query results to match the order of an array of user IDs?

I'm using WP_User_Query to get a list of users from my database. I'm showing specific users only via use of the include parameter. For example: $args = array( 'include' => array( 1, 3, 5, 99, ...
2
votes
1answer
4k views

pre_user_query meta_query admin user list

I'm attempting to use pre_user_query' to change the query to include somemeta_query` variables. My goal is to only display users in the user list if they share a common meta_value with the current ...
2
votes
1answer
406 views

How to display next and prev pagination links with WP_User_Query?

Looking through the pagination functions available in WordPress, most seem to be associated with posts. paginate_links() seems to be the only function which will work with WP_User_Query. However, when ...
2
votes
1answer
6k views

WP_User_Query with combined meta query - not working?

I'm trying to use WP_User_Query class to list all users basing on their specific meta fields. When I use simple single-meta query, it works fine: $q = new WP_User_Query( array( 'role' => ...
2
votes
2answers
2k views

WP_User_Query order by meta_key that is an array

I have set a user metadata named achievements which is an array containing various numeric values. Using WP_User_Query, I want to order the list by a specific key within this array named points. The ...
2
votes
1answer
117 views

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

I'm trying to create an archive of users. My first thought was to use WP_User_Query inside a page to create a secondary loop. $wp_user_query = new WP_User_Query( $args ); // Loop here. This ...
2
votes
1answer
3k views

How to use search_columns in WP_User_Query?

I am using WP_User_Query to search use by name, ID, email etc... In that case I need to use search_columns field to pass ID or email of user. What i am doing is $my_users = new WP_User_Query( ...
2
votes
1answer
34 views

User Relationship

I have created a custom registration page, whereby a person will receive a code from another user and type in a code upon registering. If the code matches, i need the user who has just registered to ...
2
votes
1answer
7k views

Searching user meta using WP_User_Query

Per the documentation for WP_User_Query, there is an available search parameter. It looks something like this: $users = new WP_User_Query(array( 'search' => 'This is my search' )); You can ...
2
votes
1answer
1k views

Query Users by login, meta & role

I'm using pre_user_query to limit the results shown on the users.php page. I am limiting it by role & also by a meta field, so my query from like this: $query->query_from = " FROM ...
2
votes
1answer
219 views

How to customize user search

I'm developing a custom user search and I'm using this plugin found here: <?php function sul_user_listing($atts, $content = null) { global $post; extract(shortcode_atts(array( "...
1
vote
2answers
895 views

How to query users who have empty first_name?

So far I have tried these three options and all 3 of them are not working. Option 1 $options = array( 'meta_key' => 'first_name', 'meta_value' => '', 'meta_compare' => '=',...
1
vote
2answers
2k views

How to get a list of all users registered before a given date?

I was expecting to be able to do something like the following which I thought would return all users that have registered before a given date: $args = array( 'post_type' => 'post', '...
1
vote
2answers
504 views

List Users alphabetically with heading

How can I show a list of Users with alphabetical headings? For example: AAdamAlan BBillBob I've found examples that do it with Posts, but I can't figure out how to make it work with WP_User_query() ...
1
vote
3answers
1k views

Pagination not working on custom query

I am trying to change pages when I search by category on my website. When I am not searching under a certain category I can switch pages fine but when I am searching for a category I am unable to ...
1
vote
1answer
1k views

WP User Query fails when searching meta queries and search columns

I'm building an advanced User search using WP_User_Query but experiencing some unusual behaviour. I'm trying to search with a term that I know exists in the user_nicename and user_email fields but ...
1
vote
1answer
981 views

WP User Query get all authors with last name starting with specific letter

I need to program a page to which I pass an initial through the url and it will show all author users whose last name starts with that letter. I would like to do this via WP User Query so that I can ...
1
vote
2answers
2k views

Ordering WP_User_Query results by the user IDs used in the include parameter

I'm using WP_User_Query to bring back a list of users. I'm passing a list of specific users to be included in results. For example: $user_ids = array( 1, 5, 9, 61, 24, 12 ); $args = array( ...
1
vote
2answers
2k views

Wordpress User getting added with id of 0

Am adding users in the backend and have taken site from live environment and put into localhost (development environment), but I have noticed a few things on localhost (not sure if these problems also ...
1
vote
2answers
2k views

Get users in query and limit user output to five in random order

In the footer.php I show all the authors of my blog with the following code: $args = array( 'meta_key' => 'last_name', 'orderby' => 'meta_value', 'order' => 'ASC' ); // Create ...
1
vote
1answer
214 views

Basic Wp_user_query not finding any users

For some reason, the most basic wordpress user query i got from this generator https://generatewp.com/wp_user_query/ is displaying that it has not found any users $args = array ( ); // ...
1
vote
1answer
121 views

Complex WP_User_Query call fails on production server

I'm having a very specific and hard to debug problem with a complex meta_query in a WP_User_Query call: I'm using this (simplified) code to built the query: // custom user role $arguments = array( ...
1
vote
1answer
330 views

Query users by capability - uninstall/deactivate callback

The situation Running on MU, I'm writing an open source/publically and freely available plugin. As I used add_screen_option() to allow users to easily setup the admin page to their likings, I'm left ...
1
vote
1answer
37 views

Getting users by specific capability, not role

Is there a way to use the get_users() function, or maybe another way, to retrieve all users of a custom user capability? For example, I have given a select number of users the capability of '...
1
vote
1answer
18 views

Showing all users who match 2 meta fields with current user

PHP novice here... so thanks for your patience and generous answers in advance. I'm trying to show a list of all users who match two fields with the current user, but it's not working so I would ...
1
vote
2answers
142 views

Modify user table search results

Hi i am using the following to modify the results returned from a search on the users tables in wp admin : add_action('pre_get_users','custom_user_search'); $query->query_vars['meta_query'] = ...
1
vote
1answer
122 views

WP_User_Query not displaying any user [closed]

I dont understand what is wrong my code is just not working, I have tried with different $args but still no user displays. Following is my code: $args = array( 'role__in' => array('Subcriber',...
1
vote
1answer
69 views

WP_Query ordered by meta_value_num doesn't fetch posts without this meta field

I have a custom user query, which should order users by a custom meta field staff_profile_position. Users, who don't have a staff_profile_position are not fetched with this query: $args = array( '...
1
vote
1answer
1k views

WP_User_Query with meta_query array relation 'OR'

I just updated to WP 4.1 and a User_Query I was using is now returning 0 instead of the expected results. $pm = array( //'role' => 'program_manager', 'orderby' => 'display_name', '...