[wp-trac] [WordPress Trac] #16841: manually created user roles not showing in author dropdown irregardless of assigned capabilities

WordPress Trac noreply at wordpress.org
Thu May 22 04:40:20 UTC 2014


#16841: manually created user roles not showing in author dropdown irregardless of
assigned capabilities
-----------------------------+------------------------------
 Reporter:  10sexyapples     |       Owner:
     Type:  defect (bug)     |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Role/Capability  |     Version:  3.1
 Severity:  normal           |  Resolution:
 Keywords:                   |     Focuses:
-----------------------------+------------------------------

Comment (by sterlo):

 To clarify, this is all tied into this particular section:

 https://core.trac.wordpress.org/browser/tags/3.9.1/src/wp-
 includes/user.php#L649


 {{{
 $qv['meta_key'] = $wpdb->get_blog_prefix( $blog_id ) . 'user_level';
 $qv['meta_value'] = 0;
 $qv['meta_compare'] = '!=';
 }}}

 This will end up meaning "give me all users that have a wp_user_level that
 is not equal to 0".

 If you go into MySQL and run something along the lines of this:

 {{{

 [mysql> select * from wp_usermeta WHERE user_id = 19;
 +----------+---------+------------------------------+-------------------------------------------------------+
 | umeta_id | user_id | meta_key                     | meta_value
 |
 +----------+---------+------------------------------+-------------------------------------------------------+
 |      225 |      19 | first_name                   | John
 |
 |      226 |      19 | last_name                    | Doe
 |
 |      227 |      19 | nickname                     | @jdoe
 |
 |      228 |      19 | description                  |
 |
 |      229 |      19 | rich_editing                 | true
 |
 |      230 |      19 | comment_shortcuts            | false
 |
 |      231 |      19 | admin_color                  | fresh
 |
 |      232 |      19 | use_ssl                      | 0
 |
 |      233 |      19 | show_admin_bar_front         | true
 |
 |      234 |      19 | wp_capabilities              | a:1:{s:15:"content-
 manager";b:1;}                     |
 |      235 |      19 | wp_user_level                | 10
 |
 |      236 |      19 | dismissed_wp_pointers        |
 wp350_media,wp360_revisions,wp360_locks,wp390_widgets |
 |      429 |      19 | wpseo_title                  |
 |
 |      430 |      19 | wpseo_metadesc               |
 |
 |      431 |      19 | wpseo_metakey                |
 |
 |      432 |      19 | _yoast_wpseo_profile_updated | 1400732591
 |
 |      433 |      19 | googleplus                   |
 |
 |      434 |      19 | twitter                      |
 |
 |      435 |      19 | facebook                     |
 |
 +----------+---------+------------------------------+-------------------------------------------------------+
 19 rows in set (0.00 sec)]

 }}}

 The line you need to pay attention to is:

 {{{
 |      235 |      19 | wp_user_level                | 10
 |
 }}}

 When you create your custom role, you need to add something that is > 0 in
 terms of wp_user_level.

 Adjusting the role to increase the user_level is the end goal. To
 accomplish that you can use the `$role->add_cap('level_1');` method
 explained by others - as long as it is not `level_0`.

 **It is important to note that you need to edit the user and re-save them
 with the add_cap change in place. This will update the database so that
 `wp_user_level` is no longer 0.**

--
Ticket URL: <https://core.trac.wordpress.org/ticket/16841#comment:15>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list