[wp-trac] [WordPress Trac] #36341: Add a note about the 'init' hook to the DocBlock for get_current_user_id()

WordPress Trac noreply at wordpress.org
Sat Aug 13 23:30:49 UTC 2016


#36341: Add a note about the 'init' hook to the DocBlock for get_current_user_id()
--------------------------+---------------------------
 Reporter:  DrewAPicture  |       Owner:  DrewAPicture
     Type:  defect (bug)  |      Status:  accepted
 Priority:  normal        |   Milestone:  4.7
Component:  Users         |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:  docs
--------------------------+---------------------------

Comment (by johnjamesjacoby):

 `init` has been (and is currently) the proper action, based on an
 unmodified core load order.

 But, WordPress doesn't complain very loudly if anything regarding the
 current user is loaded prematurely.

 The Customizer currently modifies the load order because of the split-pane
 view. I'm still not convinced this is necessary (and have a ticket and a
 probably-stake patch somewhere) and even WordPress.com does current user
 checks very early so it can short-circuit requests that are clearly
 intended for capable logged-in users.

 The issue with this arises from plugins (namely bbPress) that don't hook
 anything in (even roles and mapped meta caps) until `plugins_loaded`, so
 when something needs to call the current user ahead of `init`, it should
 be at their own risk and with the understanding they are choosing to
 violate the core action order.

 Does that make sense? It's really one of the only places in WordPress core
 where this type of action-jump can occur, usually on accident.

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


More information about the wp-trac mailing list