Opened 11 years ago
Closed 7 years ago
#28116 closed defect (bug) (fixed)
is_user_logged_in() does not work properly after using wp_signon()
Reported by: | guusifs | Owned by: | DrewAPicture |
---|---|---|---|
Milestone: | 4.9 | Priority: | normal |
Severity: | normal | Version: | 3.9 |
Component: | Users | Keywords: | needs-docs |
Focuses: | Cc: |
Description
I encountered is_user_logged_in() does not work properly after signing a user is logged in. Work around is described here: http://blog.rhysgoodwin.com/programming/wordpress-wp_signon-current_user-is-not-populated/. Guess that could also be the (quick) fix to just call wp_set_current_user at the end of wp_signon().
Change History (9)
#2
@
9 years ago
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
Invalid per comment:1
#4
in reply to:
↑ 1
@
9 years ago
Replying to Denis-de-Bernardy:
Seems invalid though: is_user_logged_in() returns false until the init hook, so if you run your code when the plugin is loaded then it will not work indeed.
I don't think that was the issue here, I think the report was about wp_signon()
not setting the current user.
Replying to guusifs:
Why is that? It took me a long time to figure out what was wrong.
wp_signon()
is only meant to check the credentials and set the authentication cookies. If you need to check is_user_logged_in()
right away, wp_set_current_user()
should be called explicitly.
Perhaps we need better docs, but as far as I can tell, there is no bug here.
#5
@
9 years ago
Yes, that is what I was thinking, document better if this is how it works. How is that normally being done?
Seems invalid though: is_user_logged_in() returns false until the init hook, so if you run your code when the plugin is loaded then it will not work indeed.