Changes between Initial Version and Version 2 of Ticket #28468
- Timestamp:
- 07/18/2014 07:09:40 PM (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #28468
-
Property
Status
changed from
newtoclosed -
Property
Milestone
changed from
Awaiting Reviewto -
Property
Resolution
changed from
toinvalid -
Property
Summary
changed from
wp_capabalities (wp_usermeta table) actually serialized array of user_roletowp_capabilities (wp_usermeta table) actually serialized array of user_role
-
Property
Status
changed from
-
Ticket #28468 – Description
initial v2 5 5 6 6 When 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_usermeta9 [meta_key] => [wp_capabilities]10 [meta_value] => [a:1:{s:13:"administrator";b:1;}]11 7 {{{ 8 table wp_usermeta 9 [meta_key] => [wp_capabilities] 10 [meta_value] => [a:1:{s:13:"administrator";b:1;}] 11 }}} 12 12 Not 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. 13 13 … … 15 15 16 16 Also, why is the value stored like this? 17 18 serialize(17 {{{ 18 serialize( 19 19 array( 20 [administrator]=>true20 [administrator] => true 21 21 ) 22 )23 22 ) 23 }}} 24 24 Why not plain-text, like pretty much any value in the wp_usermeta table? 25 25 26 26 To 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' ; 29 foreach( $user_roles as $role ){ 30 30 $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' => '=' 34 34 ); 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 }}} 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). 38 38 39 39 When 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.