Viruthagiri

Untitled

Mar 25th, 2012
191
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Log In User
  2. function log_in_user($username, $password) {
  3.    
  4.     // Get the user based on the username from the POST
  5.     $user = parse_user($username);
  6.  
  7.     // Remove html tags from the title and content fields
  8.     $username_stripped = strip_tags($username);
  9.     $password_stripped = strip_tags($password);
  10.    
  11.     // Validate the Form Data
  12.     if(isEmptyString($username_stripped)) return new WP_Error('forgot_username', 'You forgot to enter your Username');
  13.     if(isEmptyString($password_stripped)) return new WP_Error('incorrect_password', "You forgot to enter your Password.");
  14.     if(!wp_check_password( $password_stripped, $user->user_pass ) ) return new WP_Error('incorrect_password', "You seem to have entered a wrong password.");
  15.    
  16.     wp_set_auth_cookie($user->ID, $remember);
  17.     wp_login($username_stripped, $password_stripped);
  18.        
  19.     wp_redirect(get_bloginfo('url') . '/my-account/');
  20.     exit;
  21.    
  22. }
RAW Paste Data