XHanch Studio Log in | Register | Cart

Forum

[How to] Log in a u...
 
Notifications
Clear all

[How to] Log in a user to WordPress programmatically without authentication

1 Posts
1 Users
0 Likes
1,036 Views
XHanch
(@xhanch-alt)
Posts: 2105
Member Admin
Topic starter
 

You can log in a user to your WordPress programmatically without validation (username or password) by using these PHP codes:

$username = 'an username';
if (!is_user_logged_in()) {
    $user = get_userdatabylogin($username);
    $user_id = $user->ID;
    wp_set_current_user($user_id, $user_login);
    wp_set_auth_cookie($user_id);
    do_action('wp_login', $user_login);
}
 
Posted : 16/04/2011 2:00 pm
Share:

× Close Menu