Opened 9 years ago
Last modified 7 years ago
#36341 assigned defect (bug)
Add a note about the 'init' hook to the DocBlock for get_current_user_id()
Reported by: | DrewAPicture | Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | |
Component: | Users | Keywords: | has-patch |
Focuses: | docs | Cc: |
Description
Attachments (1)
Change History (13)
#2
@
8 years ago
- Milestone changed from Future Release to 4.7
- Owner set to DrewAPicture
- Status changed from new to accepted
@johnjamesjacoby Recommendations for which hook to reference here?
#3
@
8 years ago
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.
#4
@
8 years ago
- Keywords commit added
If init
is where things are guaranteed to be ready, that's what we should promise in the docs. It's possible for things to be ready early, but init
seems like a good promise to developers.
This ticket was mentioned in Slack in #core by desrosj. View the logs.
8 years ago
#7
@
8 years ago
Patch still works for me. If everyone is happy with the wording here, I think this can get merged.
This ticket was mentioned in Slack in #docs by morganestes. View the logs.
8 years ago
This ticket was mentioned in Slack in #core by jeffpaul. View the logs.
8 years ago
This ticket was mentioned in Slack in #core by jeffpaul. View the logs.
8 years ago
#11
@
8 years ago
- Keywords commit removed
If #23016 is committed, this disclaimer will no longer be necessary.
Also, Core does not obey this rule, see ticket:29783:50.
This seems to contradict comment:19:ticket:14024.
get_current_user_id()
callswp_get_current_user()
, and while it might be uncommon to call it beforeinit
, it appears to work as expected for me onplugins_loaded
. Is there something I'm missing? :)