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

learn more… | top users | synonyms

0
votes
1answer
29 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
24 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 ...
2
votes
2answers
1k views

Sort get_users by custom field

I have a custom USER taxonomy called 'label' which also has a custom field of 'sort_order' - I am trying to return a list of users that have the label taxonomy and then sort this list by the ...
0
votes
1answer
24 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
71 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' => ...
1
vote
1answer
63 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
0answers
13 views

Custom search for users

I've coded this up and it works great to search for "John" as a wildcard: $your_search_string = 'John'; $user_list = new WP_User_Query( array( 'search' => '*'.esc_attr( ...
0
votes
0answers
15 views

track logged in user link/clicks

I'm stumped here. I'm trying to track specific links on my site and report back time stamp of when a user clicked that link. These are for specific downloads and only registered users can access the ...
1
vote
5answers
4k views

How to check if a user exists by a given id

Is there any way to check if a user id exists? I want to create a function similar to username_exists() but which returns if the id exists or not.
0
votes
2answers
1k views

Best way to get user id for get_users function?

I'm trying to make a table of users by role type. What is the best-practices method of getting the user id? My goal is to print each users first & last names, username and email. What I have now: ...
0
votes
3answers
2k views

get current user not working

I was trying this code to get current user info, but showing nothing. My WordPress version is 3.3.1 <?php wp_get_current_user(); /** * @example Safe usage: $current_user = ...
0
votes
2answers
407 views

get approved users only ( ultimate member plugin )

I am using UltimateMember and I have the settings configured that admin must approve registered users first. I now want to display the approved users meta information like faculty, email, etc. in the ...
0
votes
1answer
32 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.
1
vote
1answer
6k views

Get current user data from external PHP page

I have a PHP page at the same level as the template/theme on WordPress. I need to be able to get the current logged in user details from this page. I have tried this: require_once( ...
0
votes
1answer
148 views

Wordpress /users/me endpoint request forbidden

Using Wordpress's plugin WP REST API version 1, there is an endpoint called /users/me which response with data for the currently logged-in user. When I requested /users/me I got 403 Request Forbidden ...
0
votes
1answer
54 views

I try to add informations to User profile

I try to add information fields to User profile. But my code doesn't run! :-( In functions.php I add: function add_contact_profile($user_contact) { $user_contact['twitter'] = __('URL Twitter'); ...
0
votes
3answers
43 views

List all users based on array of domains

I would like to display a list of any users whose emails are detected to have email addresses from an array of domains. $domains = array('domain1.com', 'domain2.com', 'domain3.com'); If any users ...
8
votes
7answers
15k views

Get multiple roles with get_users

I've got some code like this: $query_args = array(); $query_args['fields'] = array( 'ID', 'display_name' ); $query_args['role'] = 'subscriber'; $users = get_users( $query_args ); foreach ($users as ...
1
vote
2answers
62 views

How to get top 10 user is based on user meta value

I'm trying to get top 10 users in my wordpress blog based on user meta value. I've tried few methods & finally able to get just top one user using below wpdb query. But clueless, how we can get ...
5
votes
2answers
1k views

How can I query all users who registered today?

I'm trying to use meta_query to return all users that have registered today : $args = array( 'meta_query' => array( array( 'key' => 'user_registered', ...
0
votes
1answer
81 views

How can I sort get_users() by any value (last_name, user defined fields and more)

I want to sort the result of get_users() by last name, first name, user defined fields or whatever. How can I achieve this while still using get_users()?
1
vote
1answer
44 views

get_users() timeout on big userbase — options to divide query?

We run a daily cron that gets all the users' data and updates their values. The problem is that get_users() is timing out because of the big userbase. Yes, I can update the php.ini file and increase ...
0
votes
0answers
130 views

Get_users doesn't return all wp user data fields after search

I want to get all wordpress users which have some string in their user_login. I use get_users with search parameter but it return only id in WP_User->data. I need all data fields (user_login, ...
0
votes
0answers
19 views

Getting ID of user being edited [duplicate]

I wonder if i can know the id of the user being edited "edit_user page" while i'm my code in functions.php page I want to get the user_id from the database, that's my database code: ...
0
votes
2answers
153 views

Get current user outside of Wordpress Multisite

How to get current logged in user in Wordpress Multisite outside of it? I tried the method for Wordpress Singlesite and it give the error Call to a member function set_prefix() on a non-object on ...
0
votes
1answer
127 views

How to set custom upload directory per user after moving content directory

I set the content and the wordpress directory of wordpress like described in the codex: define('WP_SITEURL', 'https://' . $_SERVER['SERVER_NAME'] . '/wordpress'); define('WP_CONTENT_DIR', ...
2
votes
1answer
26 views

Get users only if Gravatar is specified

I would like to retrieve a list of 12 Wordpress users, but I would like to have them randomly (at each page reload) AND only 12 users that have a Gravatar specified. Right now, I have my 12 random ...
2
votes
2answers
2k views

Can I pass two roles to the function get_users?

I want to get the users of role academic and student. I have tried using the code below (passing an array of roles, but all users are being displayed, so clearly it's not working. ...
0
votes
0answers
17 views

Member Rating/Feedback

Need help for the rating system for users. I have created a custom profile template for the user profile and try to add a feedback form. This form is submitting a custom post types and has two custom ...
3
votes
1answer
3k views

How to paginate the get_users function?

Im using the get_users function to show a custom list of users on the site. The only issue Im having a problem figuring out now is how to paginate the result. This is a sample of the function that Im ...
0
votes
1answer
76 views

How to List only the users created by a particular user

How can I list only the users created by any particular logged in user. Suppose,I'm a Subscriber and there are users already registered, I then added User1(as Associate), User2(as Subscriber). When I ...
0
votes
1answer
2k views

How to get users by a custom field / by user meta data?

I've added a custom field to users profile using the following code: /*** Adding extra field to get the the user who creates the another user during ADD NEW USER ***/ <?php function ...
0
votes
1answer
59 views

How to get a users list by who created them?

I have two users with the capability to create other users. But their roles are not same. Tom - Role is Administrator Jackie - Role is CMS Manger (a custom created role) Both have capability ...
3
votes
2answers
130 views

What is the most efficient way to search users by their display name?

Initially I thought I'd use get_users() but it turned out it doesn't support the display_name field. Then I've read about using WP_User_Query, but when I do it always exhausts the allowed memory size ...
0
votes
1answer
62 views

How do I change the home page to the registered user's profile page

I have a custom profile page for my users. I need to have wordpress redirect the homepage to the user's profile page if they are logged in. If they are not logged in or registered, wordpress would ...
0
votes
3answers
2k views

How to count get_users query?

I have been searching high and low for a way to count the amount of results from a get_users query. Most of what I found is to count the total number of posts in a post query, but nothing for ...
0
votes
2answers
215 views

get_users with Serialized Custom Meta Value

I'm attempting to use get_users to select users with only a certain meta value. In this case the meta key is extraInfo but the the values are in a serialized array. Can I pull users out like this? ...
5
votes
2answers
938 views

Custom post type support for get_users('orderby=post_count');

The default WordPress function get_users('orderby=post_count'); only orders users with the count of the posts they've made. Any idea how to modify this to support custom post types as well? UPDATE: ...
0
votes
1answer
48 views

Iterate through users and display users meta info at front-page

I have a meta field in user called columnista-destacado I need to iterate through Wordpress users and if that field has valued set (lets said equal 1) then I need to display user meta info at ...
0
votes
1answer
101 views

List of users with email and role

I'm looking to create a list of all the users on my wordpress site with their email and role. $blogusers = get_users(); // Array of WP_User objects. foreach ( $blogusers as $user ) { echo ...
2
votes
3answers
1k views

Sort users in get_users() in custom order

<?php $blogusers = get_users('include=5,6,2,7,12,8'); foreach ($blogusers as $user) { ... } ?> Right now, these users will sorted by first name. How do I sort this in the order the ...
4
votes
3answers
5k views

List users by last name in WP_User_Query

How can I list users by last name ASC when using WP_User_Query? There is an orderby parameter but looking in core it doesn't accept ordering my user meta. Anyone know how to extend WP to allow this ...
0
votes
2answers
672 views

Order get_users() by last login date. Is it possible?

I want to create a page that displays all the blog users ordered by the last login date. I've tried with the get_users() function and I can succesfully get the users' list, but not in the order I ...
0
votes
5answers
3k views

Order by first name

I'm trying to order the member list by display_name or first name ASC. http://sim.is/sim/felagatal-sim/ This doesn't seem to work. Any pointers out there? :/ $users = get_users(array( 'role' ...
1
vote
2answers
310 views

Select Multiple meta_value from WP DB; Single Query

I am trying to retrieve each user's first and last name, phone, email, and address from the usermeta table. I'm having trouble selecting multiple meta_values, each with its own meta_key, using a ...
3
votes
2answers
786 views

Display list of users who have made at least 1 post

What I would like to do is have a list of users who have contributed at least one post. I need to show the following: [User photo] | [User Name] | [User post count] e.g. [photo] Joe Bloggs(8) I ...
0
votes
2answers
235 views

Is a user_meta research case-sensitive or not

I am using the Wordpress get_users() function to search for users with a specific meta_key value. $wordpress_user = get_users( array('meta_key' => 'unique_id', ...
0
votes
1answer
3k views

get_users meta_query

I can't get meta_queries working correctly on get_users(). For the life of me can't figure out what I'm doing wrong. $args = array( 'meta_query' => array( ...
0
votes
2answers
105 views

Cannot retrieve active members only

Below is a page template where I'm trying to retrieve active members metadata (of Restrict Content Pro). Displaying users' meta is working just fine; but I can't get ONLY active members to display, ...
1
vote
2answers
1k views

Get author id from url

I am trying to get the authors user_id on a page linked to by using get_author_posts_url(),. For example http://example.com/author/John%20Smith where John Smith is user_id is 23. I need to get ...