
Untitled
// Log In User
function log_in_user($username, $password) {
// Get the user based on the username from the POST
$user = parse_user($username);
// Remove html tags from the title and content fields
$username_stripped = strip_tags($username);
$password_stripped = strip_tags($password);
// Validate the Form Data
if(isEmptyString($username_stripped)) return new WP_Error('forgot_username', 'You forgot to enter your Username');
if(isEmptyString($password_stripped)) return new WP_Error('incorrect_password', "You forgot to enter your Password.");
if(!wp_check_password( $password_stripped, $user->user_pass ) ) return new WP_Error('incorrect_password', "You seem to have entered a wrong password.");
wp_set_auth_cookie($user->ID, $remember);
wp_login($username_stripped, $password_stripped);
wp_redirect(get_bloginfo('url') . '/my-account/');
exit;
}