There is apparently an open ticket about this bug.
Here is a workaround that I tested:
$args = array(
'meta_key' => 'last_name',
'role' => 'guest-teacher'
);
$wp_user_query = new WP_User_Query($args);
$wp_user_query->query_orderby = str_replace( 'user_login', 'wp_usermeta.meta_value', $wp_user_query->query_orderby );
$wp_user_query->query();
$authors = $wp_user_query->get_results();
Problem with this is that it runs the query twice.
Related Posts:
- wp_update_user not updating
- Create custom user role (client) that can create another custom user role (employee) of that client
- How to loop through each user id?
- how to add custom user capabilities using add_user_meta or something else?
- WordPress missing user roles on local dev machine. Live site works fine
- Assign second role to user
- Display user meta by different user role
- Parent User and Child User – relate users
- Assign a role to the user who registers on a form
- How to create user specific pages (not user role!)?
- How to change user role using hook
- Check role of Username then echo something if administrator [closed]
- Problems using ‘add_role’
- Change auth_cookie_expiration for specific roles and specific login times
- Saving user meta “member_id” based on user role
- Why does user_can return false for a capability during plugin deactivation?
- Hide user fields based off capability
- Assign specific editor with custom user meta “A” to all authors with custom user meta “A” and exclude all other author access
- update_user_meta on registration but only for default role type
- How to assign a custom gender to a user role?
- REST API, get user role?
- Can i copy administrator role to another user?
- Allow user to Publish, but not Edit or Delete
- Updating User Meta with SQL Query
- Email notification for editors only
- Custom Post Type’s Capabilities map_meta_cap issues
- Adding multiple user roles dynamically
- How to prevent users with “edit_others_posts” capability from editing admin posts
- How do I allow anyone to edit a post — but not access dashboard
- Conditional Tags for Membership Levels when using Wishlist Member Plugin?
- Allow user to edit specific user with meta key using map_meta_cap
- How can I have different groups of editors only allowed to edit certain parent+subpages?
- How to let someone preview a draft?
- How to restrict access to specific pages on the back-end?
- Can you set a role as author?
- New user created as Participant rather than Contributor [closed]
- Contributor disable seeing others’ posts
- How can I disable the update notice for non-administrators?
- Where are the WordPress capabilities stored?
- Custom user roles for access to specific parts of the site
- How do I display user name, role and site name using HTML tags inside a dashboard notification?
- User Role Capabilities for WordPress Gutenberg Blocks
- Subscriber (with read permissions) cannot view Private posts
- How can I add a custom role capability to use in a custom plugin?
- How to change a user’s role conditionally to expire after two weeks
- Users create/join groups
- Add a button or radio box that update the user role
- Stop users of author role from editing already pending posts
- Reset Roles (or undo role changes on theme change)
- Plugin creation – how to add user rights?
- User restricted only show posts assigned to current user
- How to hide a HTML element based on user role
- Give Editor Access to Custom Theme Options
- Authorize users for specific pages and/or categories
- create new user role for reader
- Woocommerce Wcvendors – duplicate emails when Vendor approved
- Hide Users by user role in Worpress
- Change user role of a particular user at specific time
- How to trigger an error: “You are not allowed to edit this post.”
- allowing subscriber role to delete their own posts
- Make a single page in WordPress available only for Admin and Subscribers
- Let users edit their role from the frontend
- Restrict access to a post once it is tagged as a given status
- When using a user role editor how to find out any plugins’ or themes’ role?
- Is there a capability/User role plugin that lets you specify edit ‘posts’ not ‘custom posts’? [duplicate]
- How to assign a role to a simple visitor?
- How can I check if a visitor can read a post?
- Assigning a capability to a user role (code check)
- How to query users to count all with a custom capability and limit it to a set of roles?
- Adding a role using Members and Formidable Forms [closed]
- Set role to a guest user, it’s possible?
- wp_update_user very slow
- On action, change user role
- User role and capablities only for 1 plugin
- Add a second role when registering programmatically
- WordPress hide any html element by css when user-role
- What would cause wp_insert_user role to work sporadically?
- How can I add capability to multiple roles?
- After setting up a new Role, CPT and capabilities, the new role can’t see the featured image
- underscore not allowed in role slug?
- Custom Gutenberg Block and unfiltered_html capability
- Blank Screen Edit Page when using Editor Role
- Streamlining what roles and users see
- Can someone help me out? Why isn’t this working?
- dynamic home page according to role user
- Custom site role cannot access Appearance menu
- Set User Role based on age result from Facebook Log-In – WordPress
- Custom Role Allowing Things It Shouldn’t Be
- Change the user role based on login or theme switch
- Frontend view of normal Visitor
- Custom Role accessing the wp-option table
- used code below to allow Editor access to menus – but change permanent, how do I revert?
- Display based on specific user
- Is it possible to restrict a specific user to edit a specific custom post.
- Access to option page by role/capability
- Display and Allow users to edit their own profiles
- Set user role based on invitation code
- Extend user search in the users.php page to allow for searching by role and excluding specified email domains from the “users search” input box
- WordPress users roles wp-admin
- User roles empty