Opened 10 years ago
Closed 10 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 |
|---|---|---|---|
| Priority: | normal | Milestone: | 4.7 |
| Component: | Users | Version: | 4.4 |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: |
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
@
10 years ago
- Keywords good-first-bug needs-patch needs-unit-tests added
- Milestone Awaiting Review → Future Release
- Version 4.6.1 → 4.4
#3
@
10 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
@
10 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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Thanks for the report, it should indeed use the role name.