您需要设置cookie,我对您的代码进行了如下修改:
Updated
<?php
function parse_user($info = null, $return = \'object\') {
if ( is_null( $info ) ) {
global $current_user;
if ( empty( $current_user->ID ) ) return null;
$info = get_userdata( $current_user->ID );
}
elseif ( empty( $info ) ) {
return null;
}
if( $return == \'ID\' ) {
if ( is_object( $info ) ) return $info->ID;
if ( is_numeric( $info ) ) return $info;
}
elseif( $return == \'object\' ) {
if ( is_object( $info ) && $info->ID) return $info;
if ( is_object( $info )) return get_userdata( $info->ID );
if ( is_numeric( $info ) ) return get_userdata( $info );
if ( is_string( $info ) ) return get_userdatabylogin( $info );
}
else {
return null;
}
}
function wp_login_user_po9856($username, $password, $remember) {
// Get the user based on the username from the POST
$user = parse_user($username);
// Remove html tags from the variables
$username = strip_tags($username);
$password = strip_tags($password);
// Validate the Form Data
if(!wp_check_password( $password_stripped, $user->user_pass ) ) return new WP_Error(\'incorrect_password\', "Wrong Password!");
// User login
$login = wp_signon(array(\'user_login\' => $username, \'user_password\' => $password, \'remember\' => (bool)$remember));
if (is_wp_error($login))
return $login;
// Unset
unset($_POST);
// Custom Message
save_message( \'success\', __( \'You have successfully Login.\', \'frontendprofile\' ) );
// Redirection
wp_redirect(get_permalink( 4 ));
}
if ( \'POST\' == $_SERVER[\'REQUEST_METHOD\'] && @$_POST[\'action\'] == \'log-in\')
{
wp_login_user_po9856($_POST[\'user-name\'], $_POST[\'password\'], $_POST[\'remember-me\']);
}
?>