• Resolved Dekisugi

    (@narin1975)


    Hi

    I begin with a user_login and I want to know the ID of that user_login. So I write code this way.

    $user_login = “john”;
    global $wpdb;
    $sql = “SELECT ID FROM $wpdb->users WHERE user_login=’.$user_login.”‘”;
    $user_id = $wpdb->get_var( $sql);

    I wonder if there is a shorter way to accomplish this. Does wordpress have a function specifically for that?

    Thanks,
    Narin

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘What is the shortest way to get user ID?’ is closed to new replies.