[wp-trac] [WordPress Trac] #28374: Calling WP_User::add_cap does not flush capabilities

WordPress Trac noreply at wordpress.org
Tue May 27 08:28:07 UTC 2014


#28374: Calling WP_User::add_cap does not flush capabilities
--------------------------+-----------------------------
 Reporter:  rmccue        |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Users         |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 After calling `$user->add_cap()`, both `$user->get_role_caps()` and
 `$user->update_user_level_from_caps()` need to be called to update
 `$user->allcaps`. Ditto `$user->remove_cap()`.

 Both `$user->add_role()` and `$user->remove_role()` do this automatically.

 Steps to reproduce:

 {{{
 $user = wp_get_current_user();
 $user->add_cap('some_test_cap');
 $user->has_cap('some_test_cap');

 // -> false
 }}}

 Possibly related to #19747.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/28374>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list