Questions tagged [wp-user-query]
The wp-user-query tag has no usage guidance.
184
questions
0
votes
1
answer
46
views
Complicated `orderby` based on text in custom field
I'm doing a user query and looking to query users that are in a certain department (custom field) -- this works. Now I'm trying to manipulate the order....I'd like to use the meta_key for position and ...
0
votes
0
answers
16
views
wp_user_query with meta_value_num for leaderboard
Context : I try to make a custom leaderboard with the WP_USERS_QUERY class and the custom code below. I use the gamipress plugin for points system. The leaderboard works fine, displaying correctly the ...
1
vote
1
answer
89
views
Query a meta key using an array of values where the database value is a string
If a meta value in the WordPress user_meta table is set as a comma separated list and not a serialized array, how can we compare an array of possible values to the values in the database table?
...
0
votes
0
answers
17
views
Wordpress WP_User_Query ignores the `meta_query` when called from an Ajax function
I have an ajax function that runs the following WP_User_Query:
$args2 = array(
'meta_query' => array(
'gender' => array(
'key' ...
0
votes
2
answers
79
views
User Query Multiple Orderby Clause
I'm having trouble getting consistent results from a WP_User_Query when ordering by multiple meta values.
There is a meta field that contains a serialized list of IDs, and I need to display users with ...
-1
votes
1
answer
56
views
wp_mail function not working in user query loop
I'm trying to send an e-mail to every user who is logged in more than a year ago (based on woocommerce meta value from database), but the e-mails do not go out. In my code I'm trying to filter myself ...
0
votes
1
answer
335
views
Extend user search in the Wp backend area on the users.php page to allow for searching by email domain and role from the "users search" input box
I have been looking to extend the ability to search users in the backend for some time and have tried variations of several functions recommended in these articles and posts along with others not ...
0
votes
0
answers
30
views
Show only users with the same role in Dashboard user list
I'm trying to see in the dashboard user list only the users with the same role of the logged in user.
For example, i have Admin, Mod and Subscribers roles, when I'm a Subscriber i want to show only ...
0
votes
2
answers
65
views
Unable to do WP_User_Query with meta filter
I have a user base of hundreds of users, and trying to create a custom API endpoint to get users in a specific membership group.
The database structure is as follows (using Ultimate Member plugin):
...
0
votes
0
answers
24
views
User with same Mail but a different additional info(like domain)
I know this is not the way u should go, but my customers want it so im looking for ways.
Requirement:
WP with one DB (3 Domains sale the same stuff)
3 Domains which use this DB (can be more later), ...
1
vote
0
answers
274
views
Parent User and Child User - relate users
I need to create a system in which I have 2 types of users: Company User (C) and Employee User (E).
I need C to be able to register as many E as necessary and for C users to be able to publish ...
0
votes
1
answer
84
views
Replace wp_query with wp_user_query
I'm turning out some subscriber archives and singles (profile pages) in my plugin where I'd also included a 'user-single' template, included via template_include. I'm experimenting however with ...
0
votes
1
answer
868
views
User query - getting values for custom meta keys/fields
I am beginner at customizing wordpress but have some experience in PHP coding.
I'm struggling to figure out how to display all existing meta keys (custom fields defined by ACF) for all users that have ...
0
votes
0
answers
108
views
Getting current user data with MySQL statement
There are many widgets in Elementor which allow using MySQL statements to populate some data field. What I am trying to do is populate a field with a specific user's order data. The problem I am ...
0
votes
1
answer
152
views
How do I echo all users' display_name and their meta_value who have a certain meta_key?
I have a meta_key inside the table usermeta called 'sms_subscriber'. The meta_value for it is their phone number. I want to echo a list of all users who have that field; in other words, a list of each ...
0
votes
0
answers
87
views
Wrong result in fetching User meta of WordPress
I have custom post type Task where I assigned Users as Volunteers.
Now I would like to fetch how many tasks assigned to a Volunteer.
I am using below code.
$users = new WP_User_Query(array(
'...
0
votes
0
answers
22
views
How to query users to count all with a custom capability and limit it to a set of roles?
On a site with 12 custom user roles I need to count users with the 'supervisor' custom capability but limited to four specific roles.
The following code counts all users with the 'supervisor' ...
1
vote
1
answer
266
views
WP_User_Query ignoring 'meta_query' arguments
So, I'm trying to do a query on 'members' based on some inputs from a form using AJAX.
The thing is that when searching for a 'role' I get the expected result. But once I try to look for other meta ...
0
votes
1
answer
120
views
last_name + first_name orderby with meta_query [solved]
I have small issue with orderby. I´m looking solution to orderby ASC (lastname + firstname) example:
Selanne Andy
Selanne Beeny
Selanne Teemu
But now it arrays something like this:
Selanne Beeny
...
0
votes
1
answer
612
views
Dokan Marketplace store link in single product page
I use this this way to display product store link with [vendor_shop_name] shortcode in custom product page.
/*Shortcode [vendor_shop_name] https://stackoverflow.com/questions/55364574/display-dokan-...
0
votes
0
answers
31
views
Issue with user meta_query
I am creating a zip code radius search. I am pulling the all the zip codes within a radius depending on the search term through an API, then doing a user query to compare a custom meta field that has ...
0
votes
1
answer
151
views
Get a Post Loop based on Logged in User information into a Shortcode
I have a follower button on users profiles where users can follow other users. I have a page template that shows all posts by users the currently logged in user follows. I would like to create a ...
0
votes
1
answer
278
views
array of meta values using WP_User_Query
I don't see that it is possible when I look at the WordPress documentation but I wanted to confirm. I want to check multiple meta values against one meta key eg:
$user_query = new WP_User_Query( array(...
1
vote
1
answer
384
views
Wordpress search posts by author name with autocomplete
I am using autocomplete code as follows:
functions.php
// add the ajax fetch js
add_action( 'wp_footer', 'ajax_fetch' );
function ajax_fetch() {
?>
<script type="text/javascript">
...
2
votes
1
answer
52
views
Echo the number of users using WP_User_Query?
Ok, so right now I can easily echo the number of posts that has a specific meta_key and meta_value:
$query = new WP_Query(
array(
'meta_key' => 'usp-custom-1',
'meta_value' =&...
0
votes
0
answers
40
views
Link multiple user databases together?
Okay, so I am helping in website design and social media aspect of a game my friends are developing, and I want to be able to sync my Wordpress user database, game wiki user db and the game's database....
0
votes
0
answers
142
views
How to filter and/or sort user taxonomy query inside custom user taxonomy archive page?
I am looking for some assistance with how I can filter AND/OR sort my WP query while on a taxonomy page. Essentially, what I am looking to do is have all users listed in alphabetical order on the ...
0
votes
0
answers
500
views
Query users and count totals based on meta values
Users can choose a value from a multiple choice checkbox on sign up. In this example the choices are Cat or Dog.
I have a WP User Query and want to count the amount of users that have each meta value, ...
0
votes
1
answer
157
views
How to combine two get_users() array?
The $q1 and $q2 are working well individually.
if (!empty($search_term)) {
$q1 = get_users(array(
'fields' => 'all',
'role' => 'contact',
'search' =&...
0
votes
2
answers
179
views
Can you return users of a higher role than the current user using get_users()?
I am using get_users() to return a list of users with specified roles. The purpose of this is to generate a dropdown on the front end to mention other users in comments, very similar to the ...
0
votes
0
answers
65
views
Compare time value in WP_User_Query for sending emails
I am trying to setup a custom plugin that will compare the time (last activity of a user) and send emails to them. I am using the below WP_User_Query and a cron job
function reminder_email() {
// Get ...
0
votes
0
answers
73
views
How to optimize the opening speed of admin panel?
Now my access to the WordPress post editing page is abnormally slow and I have to wait 30 seconds or more for it to finish loading each time.
Initially, I thought it was a problem with the network ...
0
votes
1
answer
86
views
Random users always showing same 8 users
I am trying to display some random users on the page. It is changing the order of the users it is showing, but it is only showing the same users instead of randomizing from all users in the database.
...
1
vote
0
answers
168
views
Four columns in the wp_users table
I am writing custom code to allow users of my site delete their own accounts from the front-end (i.e., they do not have to logon to the WordPress admin area to perform certain actions, but rather I ...
0
votes
1
answer
697
views
Display the list of user's comments + the post title + date
I am trying to display the current user's ALL comments in a specific page and I'm using this code (uses a shortcode): https://blog.ashfame.com/2011/01/show-recent-comments-particular-user-wordpress/
...
0
votes
1
answer
894
views
SQL to set Display Name to First Name + Last Name
I'm trying to set the wp_users.display_name for a rather larger users db using SQL query.
Got till this point:
SELECT x.display_name, x.first_name, x.last_name
FROM
(SELECT
u.display_name,
f....
1
vote
0
answers
16
views
User Query sort on custom field then name
I am trying to sort a list of attorneys (set up as Users) classified as founding members, members, and associates. Those classifications are stored in the attorney_title meta field.
I need them to ...
0
votes
0
answers
245
views
Cannot update newly added User field using wp_update_user
I want to add a new attribute to the wp_user table, "twitter_id" for example.
I added the new column to the wp_user table, and it is added correctly. I get the current user (as I want to ...
0
votes
0
answers
114
views
How to grab data after wp user search is complete
In the wp backend wp-admin > users.php there is a search field which we can use to search for particular users.
Let's say we search for a string 'test' and it retrieves 3 users.
How can we grab the ...
1
vote
0
answers
22
views
how to know when the user is in specific part of the website and when he leaves that part and display the data in the admin dashboard
I want to display for the admin when a user visits a page and when he leaves that page
the page is for example test.test/my-dashboard. and it's only available for the logged in users.
the admin knows ...
0
votes
1
answer
2k
views
I imported an restore an database and It shows #1067 - Invalid default value for 'user_registered'
My database tables become corrupted so for fixing them I restored data and It shows an error #1067 - Invalid default value for 'user_registered' how can I fix it.
0
votes
0
answers
25
views
SQL to join u3g_users & u3g_meta_value with repeating data
I'm using the below SQL to create a table from wordpress user information joining data in u3g_users and u3g_metavalue.
SELECT u3g_users.`ID`,
u3g_users.`display_name` AS `Name`,
...
1
vote
0
answers
98
views
How to show user online status on their posts?
I've tried a lot to solve this but of no use. I have a classified wordpress website where users can post their ads. I want to show their online status on the ad they post (archive and single posts as ...
0
votes
1
answer
191
views
Getting user data via ajax
I am trying to list registered users on the frontend which have a role of 'member'. I have a lot of advanced custom fields for the users though and don't know how to get those fields. I installed the '...
0
votes
1
answer
193
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
2
answers
250
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
2
answers
696
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
2
answers
551
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
2
answers
932
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
1
answer
202
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 ...