Skip to content

Instantly share code, notes, and snippets.

@someguy9
Created May 26, 2020 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save someguy9/f403b1a685230c756056915e7e922822 to your computer and use it in GitHub Desktop.
Save someguy9/f403b1a685230c756056915e7e922822 to your computer and use it in GitHub Desktop.
Gets the user ID by email in WordPress
<?php
//Get user ID by email
$user_data = get_user_by('email', 'your@email.com');
$user_id = $user_data->ID;
$user_email = $user_data->user_email;
if(!empty($user_id)){
echo 'The user ID for '.$user_email.' is '.$user_id;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment