Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

Wordpress user login code example

$creds = array(
    'user_login'    => 'example',
    'user_password' => 'plaintextpw',
    'remember'      => true
);

$user = wp_signon( $creds, false );

if ( is_wp_error( $user ) ) {
    $msg = $user->get_error_message();
}else{
  wp_clear_auth_cookie();
  wp_set_current_user ( $user->ID ); // Set the current user detail
  wp_set_auth_cookie  ( $user->ID ); // Set auth details in cookie
  $msg = "Logged in successfully"; 
}
Source by wordpress.stackexchange.com #
 
PREVIOUS NEXT
Tagged: #Wordpress #user #login #code
ADD COMMENT
Topic
Name
9+7 =