Opened 12 years ago
Closed 9 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 |
|---|---|---|---|
| Priority: | normal | Milestone: | 4.9 |
| Component: | Users | Version: | 3.9 |
| Severity: | normal | Keywords: | needs-docs |
| Cc: | Focuses: |
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
@
11 years ago
- Milestone Awaiting Review
- Resolution → invalid
- Status new → closed
Invalid per comment:1
#4
in reply to: ↑ 1
@
11 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
@
11 years ago
Yes, that is what I was thinking, document better if this is how it works. How is that normally being done?
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
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.