Skip to content

Instantly share code, notes, and snippets.

@psorensen
Created August 5, 2016 19:20
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 psorensen/4d617e32e80faa1f9c3e852fe6199780 to your computer and use it in GitHub Desktop.
Save psorensen/4d617e32e80faa1f9c3e852fe6199780 to your computer and use it in GitHub Desktop.
Wordpress: Find If User exists by ID
/**
* Determine if user exists by ID
* @param int $user_id User ID
* @return bool true if user exists
*/
public function user_id_exists( $user_id ){
global $wpdb;
$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->users WHERE ID = %d", $user ) );
return $count === 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment