Make WordPress Core

Changes between Initial Version and Version 2 of Ticket #28468


Ignore:
Timestamp:
07/18/2014 07:09:40 PM (12 years ago)
Author:
SergeyBiryukov
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #28468

    • Property Status changed from new to closed
    • Property Milestone changed from Awaiting Review to
    • Property Resolution changed from to invalid
    • Property Summary changed from wp_capabalities (wp_usermeta table) actually serialized array of user_role to wp_capabilities (wp_usermeta table) actually serialized array of user_role
  • Ticket #28468 – Description

    initial v2  
    55
    66When searching for users from a certain user_role a little trickery has to be used to be able to find the correct users.
    7 
    8     table wp_usermeta
    9     [meta_key] => [wp_capabilities]
    10     [meta_value] => [a:1:{s:13:"administrator";b:1;}]
    11 
     7{{{
     8table wp_usermeta
     9[meta_key] => [wp_capabilities]
     10[meta_value] => [a:1:{s:13:"administrator";b:1;}]
     11}}}
    1212Not only is this a weird way to store this value, with an incorrect meta_key assigned, in this case it's also an incorrect value.
    1313
     
    1515
    1616Also, why is the value stored like this?
    17 
    18     serialize(
     17{{{
     18serialize(
    1919    array(
    20     [administrator]=>true
     20        [administrator] => true
    2121    )
    22     )
    23 
     22)
     23}}}
    2424Why not plain-text, like pretty much any value in the wp_usermeta table?
    2525
    2626To get the correct users to be returned a query now has to be submitted with a meta_query like so:
    27 
    28     $roles[ 'relation' ] = 'OR' ;
    29     foreach( $user_roles as $role ){
     27{{{
     28$roles[ 'relation' ] = 'OR' ;
     29foreach( $user_roles as $role ){
    3030    $roles[] = array(
    31     'key'       => 'wp_capabilities',
    32     'value'     => serialize(array($role=>true)), /* This value gets stored as: serialize(array(1){[$key]=>bool(true)) when it's created */
    33     'compare'   => '='
     31        'key'       => 'wp_capabilities',
     32        'value'     => serialize(array($role=>true)), /* This value gets stored as: serialize(array(1){[$key]=>bool(true)) when it's created */
     33        'compare'   => '='
    3434    );
    35     }
    36 
    37 Also, the record underneath (with every user apart from 'super-admin' roles) shows [meta_key]=>0, with super-admins: [meta_key]=>10. The usage of wp_user_level has been deprecated since WP3.0, so why is that still being used? (source: http://codex.wordpress.org/User_Levels).
     35}
     36}}}
     37Also, the record underneath (with every user apart from 'super-admin' roles) shows `[meta_key] => 0`, with super-admins: `[meta_key] => 10`. The usage of wp_user_level has been deprecated since WP3.0, so why is that still being used? (source: http://codex.wordpress.org/User_Levels).
    3838
    3939When using custom user_roles with custom capabilities this is very much so annoying to work through. Especially since there appears to be no reliable way to get the users of a specific user_role.