Skip to content

Function

Handle auto-login after registration.

tml_handle_auto_login( int $user_id )

Parameters

$user_id int
The user ID.

Source

function tml_handle_auto_login( $user_id ) {
    if ( ! tml_allow_auto_login() ) {
        return;
    }

    if ( is_user_logged_in() ) {
        return;
    }

    // A followed activation link alone must not log the visitor in.
    if ( in_array( current_filter(), array( 'wpmu_activate_user', 'wpmu_activate_blog' ), true ) && ! tml_is_post_request() ) {
        return;
    }

    if ( 'wpmu_activate_blog' === current_filter() ) {
        $user_id = func_get_arg( 1 );

        // Core reuses any existing account matching the signup's username.
        if ( (int) tml_get_data( 'activation_new_user_id' ) !== (int) $user_id ) {
            return;
        }
    }

    wp_set_auth_cookie( $user_id );
}

Uses

Changelog

VersionDescription
7.0 Introduced.