Questions tagged [wp-user-query]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
15 views

is_user_logged_in() throwing undefined function error

I am running this simple conditional statement on my plugin page: if (! is_user_logged_in()) { add_action('init', 's8w_ajax_login_init'); } It is throwing a fatal undefined function error for ...
0
votes
2answers
17 views

Find count of WordPress users by role and search string for user name

I want to get the total number of results after searching WordPress users by role and a string that matches the user name. What I tried so far: $args= array('echo'=>false, 'role' => 'author', '...
1
vote
2answers
22 views

pagination with numbers for WP_User_Query

I have pagination with next/previous links but I also would like to show numbers so the user can click on 2, 3, 4 etc. Pagination seems more tricky with WP_User_Query as there isn't any default ...
0
votes
2answers
30 views

meta query based on month regardless of year

For each user on my site I store a birthday using ACF date field (stored as YYYYMMDD). Is there a way to construct a meta query to retrive all users that their birthday on that specific month ...
0
votes
0answers
13 views

Display the line breaks in user bio without using html

User fills their user bio using Formidable forms. It saves correctly and displays with line breaks in Worpdress admin on the user overview page. It displays without line breaks on the site. The only ...
0
votes
1answer
29 views

How to display replies to his comments in user profile of current user

How to display list of replies to his comments in user profile of current user. my website can send notification that example: "someone replied to your comment" and when i click the link ...
0
votes
0answers
15 views

How to do WP_User_Query for Nested Array value Inside Nested Array field

i am still new in wordpress development and try to playing with WP_User_Query right now. I have meta field, with this value: array ( 0 => array ( 'address' => array ( '...
0
votes
1answer
34 views

wp_get_current_user return ID = 0 when used outside of wordpress, such as webhook / fulfillment dialogflow

I want to get the user ID that is currently logged in. I did it successfully when accessed via a web browser. However, when this function is called via dialogflow as webhook / fulfillment it always ...
0
votes
1answer
47 views

How to properly use AND / OR in custom search

I have a text field and a drop down with country names. If I use OR and only fill in the text field with a person's name it brings back incorrect results. If I type in the name and select a country, I ...
0
votes
0answers
18 views

A specific User must select a parent post to publish a post

function wbg_custom_attribute($pages, $parsed_args){ global $wpdb; $user = wp_get_current_user(); //print_r($output); //print_r($pages); if ( in_array( 'translator', (array) $...
2
votes
1answer
127 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, ...
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
2answers
76 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
40 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 ...
0
votes
0answers
16 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
210 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
95 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
35 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' => ...
1
vote
1answer
134 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
147 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
61 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
112 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
26 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
206 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
73 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
39 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
120 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
184 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
1answer
57 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
95 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
62 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 ...
0
votes
1answer
274 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
254 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
35 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
598 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
152 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
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
80 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
103 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 ...
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
2answers
987 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
238 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
1k 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
1answer
216 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 ...
2
votes
1answer
147 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 ...