get user id from username or email without logging in I want to get the user id and role before the user is logged in.  If i have the email or username, what function can I use with D8 to get the user id ?
You can load the user with loadByProperties():

$users = \Drupal::entityTypeManager()-&gt;getStorage('user')
  -&gt;loadByProperties(['mail' =&gt; $mail]);
$user = reset($users);
if ($user) {
  $uid = $user-&gt;id();
  $rids = $user-&gt;getRoles();
}