0

I'm trying to return user data based on an email input, code is simply:

$email = '[email protected]';
$user = get_user_by( 'email', $email );

This returns nothing and when I try filter_var($email, FILTER_VALIDATE_EMAIL) it tells me that the email isn't valid.

When I hard code the email into the function it retrieves the information correctly:

$user = get_user_by( 'email', '[email protected]' );

What am I doing wrong in the first code snippet?

1
  • I have try to check this and it is working fine as you can check in an attached screenshot https://ibb.co/CvBk4Ww The issue may be with the data type so could you please try var_dump($email) so it's data type can be checked, also if possible please share whole code so I can check this. Commented Jul 15 at 9:24

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.