How to automatic login in wordpress.



//if "test@example.com" is already registered

$user_email="test@example.com"

$pl_userid=email_exists($user_email);

wp_set_current_user($pl_userid, $user_email);

// set the WP login cookie
$secure_cookie = is_ssl() ? true : false;
wp_set_auth_cookie( $pl_userid, true, $secure_cookie );

do_action('wp_login', $user_email);

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s