Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!

Untitled

By: Viruthagiri on Mar 25th, 2012  |  syntax: PHP Brief  |  size: 0.90 KB  |  views: 133  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. }