Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [wp-user-query]

The tag has no usage guidance.

0
votes
1answer
31 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 ...
0
votes
1answer
372 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,'...
0
votes
1answer
441 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 ...
1
vote
1answer
10 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
39 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 ...
0
votes
1answer
497 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 ...
4
votes
1answer
481 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
560 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
2answers
718 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 - ...
0
votes
1answer
1k 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
41 views

Query users by custom field

I want to get the users who registered within last 7 days, and meanwhile who have uploaded custom avatar. I've added a function allowing users to upload their own avatar img with a custom field ...
1
vote
2answers
1k 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
31 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
23 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
32 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
49 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
556 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
21 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
22 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
27 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 ...
1
vote
1answer
35 views

Upload Video and preview

I have a question about videos in WordPress. Is it possible to let my users upload videos and show the preview in their profiles? Not have a video post page, just the user can see a preview in low ...
0
votes
1answer
36 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
228 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
12k 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
973 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
0answers
96 views

Users front end search using WP_User_Query in foreach loop

I'm looking to output a link to the users profile link so the searched username is clickable, please see the following code that's sitting in search.php: <?php $...
0
votes
1answer
39 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
90 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
27 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
349 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
34 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;} ...
3
votes
2answers
26k 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 * ...
1
vote
1answer
74 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 ...
0
votes
2answers
1k 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
44 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
51 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
45 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 ...
2
votes
2answers
785 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, ...
9
votes
2answers
21k 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 ...
0
votes
2answers
531 views

Add Watermark to PDF's of logged in user in WordPress upon upload to media library [closed]

How can I add a watermark to my PDFs that are uploaded via the media library of the logged in WordPress User when viewing and printing the pdf. I have tried utilizing plugins but they are all limited ...
0
votes
1answer
138 views

WP_User_Query and user posts

I queried a list of users using WP_User_Query from which I got the avatar, name and a few ACF that I created for the user registration. Now, I need to obtain a post list of each of the users in my ...
1
vote
2answers
724 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' => '=',...
0
votes
2answers
759 views

WP_User_Query orderby meta_val_num

I know that normal WP_Query's can have an "orderby" parameter of "meta_value_num", but when I try to user "orderby" => "meta_value_num" on a WP_User_Query, it doesn't seem to work. Anyway I can ...
0
votes
1answer
172 views

Problem with WP_User_Query when 'meta_value' is an array

I have a problem with listing my users, who have a birthday today (for this instance today is March 3rd). I've created a custom field 'birth_date' using tutorial here with some minor tweaks. My ...
3
votes
1answer
92 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 ...
3
votes
1answer
335 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 ...
1
vote
0answers
494 views

Is there a maximum limit of the number of users returns by WP_User_Query?

I’m working on a search form which filters the users . Everything works but the result is always limited to 299 users. Here is my code which is vers basic : $args = array( 'orderby' => '...
0
votes
1answer
84 views

construct complex queries with WP User Query

Is it possible to create complex query with WP User Query ? With WP Meta Query, we can make complex queries with Nested arrays like : $meta_query_args = array( 'relation' => 'OR', // Optional,...
1
vote
1answer
60 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( '...