Questions tagged [wp-user-query]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
9
votes
2answers
47k 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 * ...
0
votes
1answer
2k views

Wp_user_query search by meta_key not returning any results

I have a search form, and im trying to have it be able to search both the basic user field (user_email, display_name, etc), plus 1 other custom user meta key called "clinic" heres the argument i have ...
0
votes
0answers
28 views

WP_User_Query using meta_query with multiple fields not working, returns everything?

I have searched and tried various suggestions, to no avail. If I don't use meta_query and just use a single set of args it shows the proper matches, but when multiple fields are introduced the whole ...
0
votes
2answers
884 views

WP_User_Query not returning users with meta - what am I missing?

I think I'm missing a step here, but for the life of me I can't see it. I'm trying to display a simple list of users who all have the same role and have the same meta data value for a certain key - ...
2
votes
1answer
121 views

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

I want to list user based on the sub category (which is a taxonmy). It displays users from all the sub category rather than the one I select the sub category from the back end. The code is below, ...
0
votes
1answer
461 views

How to order users alphabetically by name? in plugin UPME

I have this code: <?php class UPME_List_Cards { public $upme_options; public function __construct() { global $upme; add_shortcode('upme_latest_members_list', array($this,'...
1
vote
0answers
31 views

Snippett for create field in registration for users

I have this code that creates a field in the user record, but it is not showing up in the user search. Apparently it seems to be saving or what is entering in the field, but I would like to be able to ...
0
votes
1answer
566 views

WP_User_Query is Not Displaying Results

I'm trying to create a table with a list of users and it only seems to work when I have it set up like this: $user_report_query = new WP_User_Query( array( 'role' => 'Administrator' ) ); The ...
0
votes
2answers
43 views

meta_query in WP_User_Query not working - returns every user, not just users where key & value matches

I've been going at this issue for hours now, and please save me before i go crazy..... I'm trying to use Wordpress' WP_User_Query to retrieve users from db I've been feeding it with arguments like ...
0
votes
0answers
30 views

Get label in user meta query

So I have a function that creates a mailing list of all users that have a specific user meta key checked using shortcode attributes. The function works well but I can't figure out how to display the ...
4
votes
1answer
514 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 ...
0
votes
1answer
821 views

WP User Query with meta queries

I'm having some problems when comparing integer values '>=' or '<=' with meta_queries with the WP_USER_QUERY. Let say I've stored the following meta keys with the meta values below: meta_key ...
0
votes
1answer
629 views

Query Users by post count, last 30 days and display each users post count according to post type

I'm almost done, the code below does everything but display post count for each user broken down into post types, and also I'm like to filter it last thirty days. I'm trying to get the post for each ...
0
votes
0answers
12 views

WP_User_Query with multiple meta_query values not returning results

I want to return a query with the users that match 2 values of user metadata, this is the code I have, but returns the users without the filter, if i add in the relation "AND" instead of "OR" wont ...
0
votes
1answer
138 views

get_users / WP_User_Query returns empty when logged out

I have a fairly basic user query pulling staff members on a website I'm working on. When you are logged in to WordPress they are showing on the front-end. But when logged out they are not displaying. ...
0
votes
0answers
52 views

Create a unique username with validation on wordpress registration

I want to add a unique username on registration and hide this field on the registration form. Its working so far, but its not 100% perfect, because if its 3 times the same number then it will throw a ...
0
votes
0answers
29 views

WP_User_Query Orderby Not Working

If I use the following code, I can retrieve users in the correct order: $user_query = new WP_User_Query( array( 'role__in' => wp_parse_list( $atts['userrole'] ), 'meta_query' => ...
13
votes
2answers
27k 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 ...
1
vote
1answer
87 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 '...
0
votes
1answer
119 views

Why get_users() not working on the admin backend?

I can't figure out why get_users() works on the frontend but not on the admin backend. I'm sure this was working at some point. My code: function add_new_user_menu_item() { remove_submenu_page('...
0
votes
1answer
57 views

Can I use paginate_links() to add a pagination list, yet prevent it from inserting links?

My page displays a list of WordPress users. For pagination, I have used the function paginate_links. This inserts a list onto my page e.g. page 2 page 3 page 4 (screenshot). And each list item is a ...
0
votes
0answers
92 views

WP_User_Query Search Multiple Keywords from a Multi-Select Field?

My code below works to list a single user when I ask to search for a single username; however, I am unable to list multiple users when asking to search for multiple usernames. Here is a brief ...
0
votes
1answer
39 views

Normal PHP array for exclude section of WordPress query?

I just wanted to check on something with the community here and avoid any future drama. I have a variable which seems to be working fine in a wp_user_query but not sure if I'm missing something that ...
1
vote
1answer
24 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 ...
0
votes
1answer
191 views

WP CLI - show users whose ID is larger than given ID

The below code achieves what i need for given ID = 200. wp user list --role='customer' --orderby=ID --order=asc | awk 'FNR == 1 {next} $1>200 {print ;}' How to do it with wp user list and WP ...
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 ...
0
votes
1answer
66 views

How to query 5 users in random who have published more than 10 posts

I want to display 5 users who have published more than 10 posts, when the page loaded again, it should show another 5 users or mixed with new users with more than 10 posts. How do I achieve this? ...
0
votes
1answer
38 views

How to get the count

How to get the count of the WP_User_Query result while I use $query = new WP_User_Query( $args ); echo count($query); It returns 1 when there is no user. But I need 0 in that case. How can I get ...
1
vote
0answers
108 views

WP_User_Query - searching multiple fields

I have a search engine where I can search for users on the front end. Profiles have mulitple custom fields. I'm just searching first and last name in this example. The problem is I can search for a ...
0
votes
1answer
173 views

WP_User_Query with 2 sets of conditions 'AND'

I would like to write some arguments for my query and both need to be true. I am having trouble with the Syntax. 'meta_key' => $campaign_type, 'meta_value' => $Campaign_ID, AND 'meta_key' => '...
0
votes
2answers
818 views

How do I sort a WP_USER_QUERY by multiple meta fields?

I've got the following WP_USER_QUERY in WordPress: $args = array( 'orderby'=>'meta_value', 'meta_query' => array ( 0 => array( 'key' => 'last_name', ...
0
votes
1answer
54 views

Periodically Query an external API on wordpress site

I am creating a wordpress site that will periodically retrieve data from an API and use that data to update info in the wp_users table. I don't really know how to go about this. I'll start with 2 ...
1
vote
0answers
24 views

What's the proper way to add users to my site in order to test things?

I'm new to wordpress. I'm have my site just running on localhost and want to test some things out with dummy data/made up users. When I log in to my wordpress database, I see that there is a table ...
2
votes
1answer
75 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 ...
0
votes
1answer
49 views

How can I prevent certain custom roles from seeing other custom roles on the user list page?

So I am building a system with 3 different custom roles - Admins, Providers, and Users. Providers have access to users.php, or the list users page. However, they should not be able to see/edit/access ...
6
votes
2answers
1k 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 ...
10
votes
3answers
14k 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 ...
1
vote
3answers
2k 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 ...
0
votes
1answer
191 views

Get users between user ids

How select users between 100 and 200 user ID's? Or select users which ID less then 200? $args = array ( 'query' => array( array( 'key' => 'ID', 'value' ...
1
vote
2answers
225 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'] = ...
0
votes
0answers
34 views

unable to modify user table search results based on meta key

I would like to modify the pre_user-query wp_user_query to include a meta fields from the user meta. I have tried the two following methods, neither of which work (both return empty sets): $query-&...
3
votes
2answers
547 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 ); $...
1
vote
1answer
39 views

Get users that likes the post

I have an ajax like posts system when a user like a post the system added a post meta to the post and it's named (post_liked_users). Example of post_likes_users meta value: a:1:{s:6:"user-1";i:1;} ...
1
vote
1answer
146 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
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
2answers
3k views

WP_User_Query unable to retreive all user at once

I have more than 3000 users with role 'subscriber', and now i want to fetch all users with role 'subscriber'. $user_query = new WP_User_Query( array( 'role' => 'Subscriber' ) ); $users = $...
0
votes
0answers
59 views

WP_User_Query not searching numbers?

I'm running this code: $users = new WP_User_Query( array( 'search' => '*63.19-4-00*', 'meta_query' => array( 'relation' => 'OR', array('key' => 'field_1'...
0
votes
1answer
74 views

WP_User_Query counter not updating with pagination

Below is the code that I found (thanks to The_Sumo) on this link and the code works like a charm. I am trying to add an additional column to the table that displays the ordered list number of the ...
0
votes
1answer
93 views

creating new field on mysql

I would like to add extra sections like "gender" on the WordPress user database. I would like to draw information from this information later. For example, let's say I want to attract gender. I ...
3
votes
2answers
1k 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, ...