Load user by specific role

One possible way is by using the role__not_in parameter like so which excludes all other roles except subscriber: // Include only the following role(s): $roles_in = array( ‘subscriber’ ); $roles_not_in = array_diff( array_keys( wp_roles()->get_names() ), $roles_in ); $args = array( ‘role__not_in’ => $roles_not_in, ); $subscribers = get_users( $args ); But of course, if you know … Read more

Nickname field isn’t appearing in Admin

When you display All Users, it will display values from users table. You will not see Nickname column, because Nickname value is in usermeta table. Put the following code to your child theme’s functions.php file. First filter manage_users_columns will add custom column Nickname to All Users view. Second filter manage_users_custom_column will retrieve values from usermeta … Read more

Is there a plugin for WordPress for creating ‘Accounts’ where all users who belong to that Account can only see Account data? [closed]

This is something that a lot of membership plugins can do, e.g. MemberPress, Restrict Content Pro, or similar membership or user group plugins. Which is best for you depends on your particular setup. From what you’re describing, you only need basic membership/group functionality (without features like payments), so I’d suggest going with a basic, free … Read more

Get user first name from custom endpoint

If you look at the documentation, first_name is not in the list of accepted values for the fields parameter, and if you enabled debugging, you’d see adding first_name to that parameter would actually cause a database error — Unknown column ‘wp_users.first_name’ in ‘field list’. And the same goes to the “firstname” and any other non-standard … Read more

Query within a foreach within a query (queryception)

Good for you that you’ve corrected the $posts that was undefined, but then: There’s no need to call $the_query->get_posts() because when WP_Query is instantiated with a non-empty query, e.g. new WP_Query( ‘post_type=house’ ) (contains one query arg — post_type) as opposed to new WP_Query() (no query args specified), the get_posts() method in that class will … Read more

WP_User_Query combining role and ids

As I was told above in the comment, WP_User_Query does not support the nested sub-arrays… So at the end I solved the thing by separated queries… Not sure whether there is more efficient way, but in case somebody needs an inspiration, below is my solution of the problem. // get ids of first set of … Read more