WordPress.org

Make WordPress Core

Opened 22 months ago

Closed 7 weeks ago

#21043 closed enhancement (invalid)

is_user_logged_in() returns true even if user is not logged in

Reported by: TomAuger Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.4
Component: Users Keywords: dev-feedback
Focuses: Cc:

Description

If you have wp_set_current_user(), then is_user_logged_in() will always return true. This goes against my understanding of the role of wp_set_current_user() especially as explained by the documentation:

"Some WordPress functionality is based on the current user and not based on the signed in user. Therefore, it opens the ability to edit and perform actions on users who aren't signed in."

But then we look at is_user_logged_in() and it just says - can we get_current_user()?

Suddenly wp_set_current_user is looking like wp_switch_logged_in_user(), which I doubt is the intent of that function.

Change History (3)

comment:1 scribu22 months ago

  • Cc scribu added

comment:2 ircbot7 weeks ago

This ticket was mentioned in IRC in #wordpress-dev by aubreypwd. View the logs.

comment:3 nacin7 weeks ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

wp_set_current_user() is a complete context switch. is_user_logged_in() is merely a reflection of that state. Changing this would break a ton.

Note: See TracTickets for help on using tickets.