[wp-trac] [WordPress Trac] #20845: wp_set_current_user( null, "name") does not work when $current_user is already 0
WordPress Trac
wp-trac at lists.automattic.com
Tue Jun 5 13:11:54 UTC 2012
#20845: wp_set_current_user( null, "name") does not work when $current_user is
already 0
--------------------------+-----------------------------
Reporter: bobbingwide | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Users | Version: 3.3.2
Severity: normal | Keywords:
--------------------------+-----------------------------
According to the documentation for wp_set_current_user() you can
Set $id to null and specify a name if you do not know a user's ID.
This does not work when the current user has already been set to anonymous
( ID = 0 ) since the following test returns true.
if ( isset( $current_user ) && ( $current_user instanceof WP_User
) && ( $id == $current_user->ID ) ) {
The last part of the test should be corrected to
&& ($id === $current_user->ID) )
which will ensure that the test fails when the $id parameter is null,
which will allow the rest of the pluggable function to continue and set
the current user to the specified $name.
This is similar to 19769.
Note: the change in 3.4 has not fixed this particular problem.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/20845>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list