Stack Exchange Network

Stack Exchange network consists of 174 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 [get-users]

Wrapper for WP_User_Query. Retrieves an array of users matching specific criteria.

0
votes
1answer
11 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 ...
0
votes
0answers
15 views

get_users() and custom meta_query with SQL procedure

I'm writing a WordPress plugin with a users listing. To build this users listing, I use the get_users() WordPress function which work perfectly. I built a form to select some options to find users ...
0
votes
2answers
9 views

User meta query results in PHP notice: only variables should be passed by reference

I am using a URL rewrite to put the user's display name in the URL to display a user profile. This part all works fine and the proper value is passed through the query_vars and I can get the correct ...
0
votes
1answer
21 views

How to avoid duplicate users when I am using get_users?

I using get_users to get users from my database. I am using this code: $args = array ( 'role' => 'Colaborador', 'role__not_in' =>[ 'subscriber', 'Administrator'], ...
0
votes
1answer
33 views

Show Wordpress users in grid with image and name

I'm looking for a way to display Wordpress users on a page in a grid. Ideally with an image and a name. It's for a face book page (not Zuckerberg's blue version) on a company's intranet. In my ...
0
votes
0answers
10 views

Get Users list by separate field.

Is it possible in WordPress or Buddy Press that get users list data as per specific field. Which field filled by user at the time of registration. For example in hospital management site The ...
0
votes
0answers
28 views

Merge wp-query and get_users

Is there a way of merging get_users() and and WP_Query() into one query so I can paginate the results? I have two entities; users and companies. Both can be members but users are users and company is ...
10
votes
3answers
452 views

How to get WordPress Username in Array format

I want to create an Autocomplete function in WordPress. I want a search field from where username can be searched. I am using following JQuery UI. <label>Users</label> <input type="...
0
votes
0answers
16 views

Finding users by a specific criteria

I want to create a website for multiple users to get together. I will be using the BuddyApp theme (https://themeforest.net/item/buddyapp-mobile-first-community-wordpress-theme/12494864). This, ...
0
votes
0answers
45 views

get_users by role returns all users

I am trying to fetch all users with a specific role eg blogger and blogger_pro but my code just returns all users rather than those with that specific role. Hope someone can tell me whats wrong? The ...
0
votes
1answer
15 views

show user based on user_meta

it's possible to show user if my logic like this it's better to give illustration USER I have two users with usermeta: user A have usermeta country with value "USA" and univ with value "UCLA" user B ...
-1
votes
1answer
105 views

file upload user profile

I am working on a medical reporting site in wordpress, where the requirement is that admin can upload a seperate .pdf file to different users' profile & only the profile owner can download it
1
vote
1answer
58 views

Get_Users Orderby Page

I've been trying to fix a sorting issue using the codex for get_users(), but I can't seem to get it working. The codex shows that I can set 'orderby' => 'post_count', but I want to change this so ...
1
vote
1answer
26 views

exclude roles from overview

I am re-using some old code on a new website where I show all users in a listing with last post image as background. This all works fine (I know the get_users_of_blog is deprecated, but when I use ...
0
votes
0answers
282 views

WP_List_Table to display subscribers including profile edit

Hoping the community can assist ,I have made a few WP_List_Tables in the past however have always been tapping into a custom database table. Now I want to tap into the WordPress user and user meta. ...
0
votes
1answer
42 views

Get the users that my following users are following

I have a social site that contains follow users system. Each user has two custom meta: following_users followers_users My question how can get the users that my following users are following? I ...
0
votes
0answers
46 views

How to get the id of recently registered user from database?

I just want to get the ID of the recently registered user using my custom created registration form. Here is my code. $user_id = wp_insert_user( array ('first_name' => apply_filters('...
0
votes
1answer
37 views

Storing data to database and user registration

The project that I'm working with have a quote form. When someone submit the quote request, the information should be stored into a new table in the database and also prompt the user to register an ...
1
vote
1answer
437 views

How to pass user meta_key and meta_value (values as array)

I want to pass user meta_key to meta_value, but the meta_value array is like this: $user_biodata = array( 'register_facebook_id' => 1311064406686333, ); I want check if user is already ...
0
votes
1answer
25 views

Query for user roles and their skills

I am trying to get all those users having role as candidate and 3 skills as follows. skill a, skill x, skill e. Only want three users, What I am missing $args = array( 'role' => 'candidate', ...
0
votes
1answer
31 views

Can someone help me out? Why isn't this working?

//Auto Delete Expired Users function delete_users(){ $bloguser = get_users( array( 'role' => 'subscriber' ) ); foreach ( $bloguser as $user ) { if ($user->user_url == 'http://day' ...
0
votes
1answer
79 views

How to search users globally on a multisite install?

I'm using the REST API to create/update/delete users on a multisite install in order to sync data with a 3rd party resource. When I am checking whether to update or create a user, I'm using the search ...
1
vote
1answer
92 views

Query users which have same dynamically generated roles as the current user

I need to check if users have the exact roles for the purpose of allow users to edit each others posts if they have a same two roles. One role 'X' is a common one, and the other role 'Y' is a unique ...
0
votes
1answer
56 views

WordPress session times out - but doesn't log out?

Since migrating our WordPress site to a new webserver, we have had issues where users are apparently getting logged out...but yet aren't. What I mean is, on our old server, users would sometimes get ...
0
votes
2answers
859 views

Get User ID from within a plugin

I want to get the current user id from inside my plugin and use it as a variable. My code is $current_user = wp_get_current_user(); $user_id = $current_user->ID; $loc_statuss = $wpdb->...
0
votes
1answer
298 views

WooCommerce Admin order - Only run action if user is loaded

I am using this plugin to switch users. I have found a snippet that allows you to switch user on the WooCommerce admin order page which is very helpful. add_action( '...
0
votes
1answer
17 views

How to retrieve custom profile fields associated with different users

I'm working on a very simple wordpress plugin that checks the database for existing users and returns specific profile fields associated with these users e.g bank account number, mobile number with ...
0
votes
1answer
63 views

List users by Year of Birth using a foreach loop to dynamically populate years and data

I have a custom meta_key called "date_of_birth" i am trying to create a table of user counts for each year based on that value. I have this code to count by specific year and also to calculate the ...
0
votes
1answer
103 views

Display current user's custom post meta in sidebar

I'm trying to find a way to display the current user's custom post (each user has only 1 post) content/meta in the sidebar, so the current user can see their custom post's meta. This is what I have so ...
0
votes
0answers
98 views

Custom user query - orderby meta_key (that may not exist)

I'm in need of someone who knows MySQL better than I do! I've started writing a custom statement, but I'm not an expert with mySQL and it's not quite there (I'm happy to scrap it entirely if there's a ...
0
votes
1answer
27 views

Paid Memberships Pro, Display User Limit

I have this piece of code I'm trying to polish up and set a limit to. Everything seems to work except for the limit part. Instead of it showing all the profiles, I only want to show 16. The value 2 ...
0
votes
1answer
589 views

Get multiple users with meta value in one query and populate WP_User class

Hopefully someone can help me with this. When you load multiple users with get_users() (let's say 100+) WP triggers the user meta query for every single user. This triggers 101 queries (main user ...
0
votes
1answer
26 views

Let logged-in users use radio buttons (yes and no) to exclude their author profile from the user listing

I would appreciate if someone could point me in the right direction because I am stuck when it comes to solving the following issue. So I have a directory listing of WordPress users (http://192.99....
0
votes
1answer
1k views

How to get user meta value in wordpress

I have created a custom usermeta field named "designation" and fetched all its meta value in loop but it shows duplicates and empty values. I have tried to resolve by using array_unique() function but ...
0
votes
1answer
73 views

Show subscriber id in loop

I want to show student (subscriber) id in a foreach loop. here is my code $args = array ( 'role' => 'student' ); $wp_user_query = new WP_User_Query($args); $students = $wp_user_query->...
0
votes
2answers
203 views

How get meta from all users?

I want to get all users with their respective data. I already get all the users: $users = array(); $users_query = new WP_User_Query( array( 'role' => 'subscriber', 'orderby' => '...
1
vote
2answers
100 views

Order users by last word of last name

This is probably a typical Dutch issue where you have a last name which can contain multiple words. For example Robin van Persie or Mark de Jong. Currently I have a list of users ordered by last name,...
0
votes
2answers
290 views

Every time I use wp_get_current_user() my plugin breaks

I have been trying to make a sign-out plugin that allows users to sign out from military training activities that they should be at. After they fill out a form explaining why they are not going to be ...
1
vote
1answer
88 views

Do not execute If User is login as Administrator or any Specific Role

How can I not execute some <script> </script> if the user is an administrator or any specific role? Basically I need to do something like this: <?php if( !User( 'Administrator', '...
0
votes
1answer
433 views

get_users meta_query: REGEXP not working for matching new lines

I have a meta field "my_meta_field" which may contain the following for these sample users: User A 99999 559225 12519 User B 5020492 99999 125191 User C 194295 1199999 Newlines are \r\n or \n. ...
0
votes
2answers
376 views

Get Sticky User in user loop based on user role

I have this shortcode to display a loop of user avatars with order by registration date. function Profiles() { $args = array( 'orderby' => 'registered', 'order' => 'DESC', '...
0
votes
1answer
32 views

How to get all posts belongs to a user between a certain date

I am writing a plugin for my company so I need to get all posts belongs to a user between a certain date which is given by another user. Then I want to count words for each post and finally add them ...
0
votes
1answer
28 views

Suggest Users basing on User taxonomy

My question is for getting informations or directions about how to move for a task I have to do. This is just a request for advices due to the fact I'm not an expert in wordpress development. My task ...
0
votes
1answer
342 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
35 views

How do I retrieve a users' last 5 posts?

How do I retrieve a particular users last 5 blog posts? Currently, I am trying the following approach, but it seems that it is retrieving the actual post titles and permalinks: <?php $...
0
votes
1answer
102 views

'pre_user_query' interfering with user export

I needed to add sortable columns to clients wordpress for custom meta data I created so I used a pre_user_query hook add_action('pre_user_query', 'user_column_orderby'); function user_column_orderby(...
0
votes
1answer
47 views

List users of specific role instead of removing them with specific role

I am currently listing all the users except users with administrator role on custom page template with: <?php $allUsers = get_users('orderby=post_count&order=DESC'); $users = array(); ...
0
votes
0answers
103 views

How can I fetch all users who are at or above X role?

What is the best way to get all users who are above a certain role, like 'author'? Is this the best way? $user_args = array( 'meta_query' => array( array( 'key' => '...
3
votes
1answer
3k views

Retrieve all users from wordpress database via REST/JSON API

I've read that the WP REST API v2 retrieves only users that have made a post for the blog. I'm developing an iOS and Android app that needs to use the Wordpress registration. How I could retrieve a ...
0
votes
1answer
247 views

How to get all logged in user id in buddypress [closed]

I want to get all buddypress logged in user's ID. for that sake i am using $bp->loggedin_user->id But this is not helping.. Please help me to get all logged in user id. Thanks.