Make WordPress Core


Ignore:
Timestamp:
02/13/2026 02:41:07 AM (6 weeks ago)
Author:
peterwilsoncc
Message:

Users: Ensure switching to current user doesn't reinstantiate current user.

Prevent wp_set_current_user() from reinstantiating the current user when the user ID is passed as a string, eg wp_set_current_user( (string) get_current_user_id() ).

This restores the function's previous behaviour of returning early in the event the IDs loosely match.

Follow up to r57882.

Props westonruter, peterwilsoncc.
Fixes #64628.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/pluggable.php

    r61537 r61633  
    3131        if ( isset( $current_user )
    3232        && ( $current_user instanceof WP_User )
    33         && ( $id === $current_user->ID )
     33        && ( (int) $id === $current_user->ID )
    3434        && ( null !== $id )
    3535        ) {
Note: See TracChangeset for help on using the changeset viewer.