Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#16556 closed enhancement (duplicate)

Search exact role name

Reported by: 082net Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0.5
Component: Administration Keywords: has-patch
Focuses: Cc:


I've added 'system-author' role and now on Admin > Users page 'author' includes users in 'system-author' role.

When wordpress search users in author role, it applied

" meta_value LIKE '%author%' "

and the result includes 'system-author' also.

This can be fixed with adding double quote(") to role name:

" meta_value LIKE '%\"author\"%' "

We can fix this issue

  1. WP_User_Search::prepare_query() from /wp-admin/includes/user.php:689
    			$this->query_where .= $wpdb->prepare(" AND $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%"' . $this->role . '"%');
  2. count_users() from /wp-includes/user.php:459
    			$select_count[] = "COUNT(NULLIF(`meta_value` LIKE '%\"" . like_escape($this_role) . "\"%', FALSE))";

Attachments (1)

exact-role-search.patch (1.4 KB) - added by 082net 5 years ago.

Download all attachments as: .zip

Change History (3)

#1 @dd32
5 years ago

If #10201 gets done in 3.2, this'll be unneeded, On the other hand, If it doesnt, this seems like a sane patch.

#2 @scribu
5 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

This is alreay fixed in WP 3.1: #12693

Note: See TracTickets for help on using tickets.