Skip to content

Instantly share code, notes, and snippets.

@feliciaceballos
Created April 29, 2016 18:31
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 feliciaceballos/eaa87e3b877e2f049eeb519ed34e4dfa to your computer and use it in GitHub Desktop.
Save feliciaceballos/eaa87e3b877e2f049eeb519ed34e4dfa to your computer and use it in GitHub Desktop.
Get User ID by display name
function get_user_id_by_display_name($display_name) {
global $wpdb;
if ( ! $user = $wpdb->get_row( $wpdb->prepare(
"SELECT `ID` FROM $wpdb->users WHERE `display_name` = %s", $display_name
) ) )
return false;
return $user->ID;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment