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 functionality of https://wordpress.org/plugins/comment-mention/.
The problem is that if the current user is in a lower role, such as an author, get_users() does not return higher roles, such as an administrator. In other words, I need a lower user to be able to return users of higher roles as well.
I realised that get_users() prevents return higher role users from here: get_users / WP_User_Query returns empty when logged out
But I wondered if there was a way around this. This is how I am getting the list of users at the moment
<?php // Set arguments. $args = array( 'fields' => array('user_login'), 'role__in' => array('administrator','editor','author'), ); // Get usernames. $results = get_users( $args ); ?>
Just a note here, the desired final result is to return an array of all usernames.