WordPress: cant derive error

I’ve got a strange one going on here. Tried to implement is_wp_error in multiple situations, but it fails. Here’s the thing, illustrated with my last attempt:

I want to login a user by wp_signon(), check if there are errors and if so, display them.

Read More

So I wrote the following lines of code:

$user = wp_signon(); 
if(is_wp_error($user)){
     $result = 'Error-' .
     $user->get_error_message(); 
} else {
    $result = 'Login succeed'; 
} 
echo $result;

The strange thing is, is_wp_error() doesn’t return false (so there is an error). But $user->get_error_message(); is empty.

Tried it in different actions. When debugging, echo is_wp_error(); returns 0.
var_dump(wp_is_error()); returns empty arrays.

Furthermore, even when valid credentials are given, is_wp_error() still returns true. Also when testing in other circumstances (and on a clean WP installation)

Any thoughts?

Related posts

Leave a Reply

1 comment