Opened 8 years ago
Closed 8 years ago
#38234 closed defect (bug) (fixed)
wp_get_users_with_no_role() generates query based on role display names not role name
Reported by: | szaqal21 | Owned by: | johnbillion |
---|---|---|---|
Milestone: | 4.7 | Priority: | normal |
Severity: | normal | Version: | 4.4 |
Component: | Users | Keywords: | has-patch has-unit-tests |
Focuses: | Cc: |
Description
This is a follow-up to #22993.
wp_get_users_with_no_role() doesn't work properly when there is and custom role eg. role name is "admin_www" and display name is "Admin WWW", function generates query:
SELECT user_id FROM wp_usermeta WHERE meta_key = 'wp_capabilities' AND meta_value NOT REGEXP 'Author|Contributor|Subscriber|Redaktor|Administrator|AdminWWW'
query should be build based on role name not display name.
Attachments (2)
Change History (8)
#1
@
8 years ago
- Keywords good-first-bug needs-patch needs-unit-tests added
- Milestone changed from Awaiting Review to Future Release
- Version changed from 4.6.1 to 4.4
#3
@
8 years ago
Explanation for the patch:
wp_roles()->get_names() returns an array in the format:
role_name => display_role_name
wp_get_users_with_no_role() uses the array value (display name) to build the regex, when it should use the array key (role name).
#4
@
8 years ago
- Keywords has-unit-tests added; needs-unit-tests removed
38234.2.patch contains both @procodewp 's original fix, and the accompanying unit test.
Note: See
TracTickets for help on using
tickets.
Thanks for the report, it should indeed use the role name.