Im using wordpress and I get a simple form to login users, which uses a login method from User class like this:
Login page
function login() {
$result = User::getInstance()->login($this->email, $this->password);
if ( is_wp_error( $result ) ) {
$this->hasErrors = true;
$this->translatableError = 'La contraseƱa no es correcta.';
} else if (isset($_COOKIE["lorraine-login-redirect"])) {
$redirectUrl = $_COOKIE["lorraine-login-redirect"];
setcookie('lorraine-login-redirect', '', time() - 3600, "/", $_SERVER['SERVER_NAME']);
wp_redirect($redirectUrl);
exit;
} else {
wp_redirect(site_url());
exit;
}
}
User class
class UserStateAnonymous implements UserStateInterface {
private $user;
private $loginUrl;
public function __construct($user) {
$this->user = $user;
}
public function login($email, $password) {
$creds = array(
'user_login' => $email,
'user_password' => $password,
'remember' => false
);
return wp_signon( $creds, true );
}
...
So... I fill login form with bad credentials but Im getting null in $result variable whereas if I do var_dump(wp_signon( $creds, true )) inside login function in User class I'm getting an error about bad credentials.
Do you know whats going on?
Thanks