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

WordPress Trac noreply at wordpress.org
Tue Dec 7 11:47:21 UTC 2021

#28374: Calling WP_User::add_cap does not flush capabilities
 Reporter:  rmccue                  |       Owner:  rachelbaker
     Type:  defect (bug)            |      Status:  closed
 Priority:  normal                  |   Milestone:  4.2
Component:  Users                   |     Version:  2.0
 Severity:  normal                  |  Resolution:  fixed
 Keywords:  has-patch dev-feedback  |     Focuses:

Comment (by pikamander2):

 This appears to still be an issue, at least in 5.8.

 I was facing the exact same problem as @lgladdy where my custom role
 wasn't receiving the capability that I added to it via add_cap().

 His blog post (https://stormconsultancy.co.uk/blog/storm-news/custom-
 roles-in-wordpress-not-appearing-in-author-lists/) mentioned changing
 their role to something else and back as a workaround, but instead of
 trying that I just deleted the user and recreated them, at which point
 they had the new capability.

 Is it possible that there was a regression here at some point?

 I see that 5.9 is going to be fixing a semi-related longstanding issue
 (https://core.trac.wordpress.org/ticket/16841), so I'd be curious to know
 if that happens to fix it on its own.

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

More information about the wp-trac mailing list