Opened 2 years ago

Closed 2 years ago

#16556 closed enhancement (duplicate)

Search exact role name

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

Description

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 2 years ago.

Download all attachments as: .zip

Change History (3)

082net2 years ago

comment:1   dd322 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.

  • 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.