只要你知道username 您可以让WP自动登录。你可能需要问你的朋友那是什么。
检查一下你是否logged in 如果没有,get user by login, set the current user 以及auth cookie 然后重定向到~~user\'s admin~~ url或edit user 更改密码的url。
将此放置在functions.php 当前激活主题的。
add_action( \'wp\', \'automatic_login\' );
function automatic_login() {
/*
|----------------------------------------------------------------
| SET THE USERNAME TO LOGIN WITH
|----------------------------------------------------------------
*/
$username = "Admin";
/*
|----------------------------------------------------------------
| AUTOMATICALLY LOG IN | THEN CHANGE YOUR PASSWORD!
|----------------------------------------------------------------
*/
if ( ! is_user_logged_in() && ! is_wp_error( $user = get_user_by( \'login\', $username ) ) ) {
// Clear any auth cookies
wp_clear_auth_cookie();
// Log the user in
wp_set_current_user( $user->ID );
wp_set_auth_cookie( $user->ID );
// Admin Dashboard
// $redirect_to = user_admin_url();
// Go directly to the Edit User page to change your password
$redirect_to = get_edit_user_link( $user->ID ) . \'#password\';
wp_safe_redirect( $redirect_to );
exit();
}
}