Created
August 5, 2016 19:20
-
-
Save psorensen/4d617e32e80faa1f9c3e852fe6199780 to your computer and use it in GitHub Desktop.
Wordpress: Find If User exists by ID
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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