Viruthagiri

Untitled

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