Yes, we can load the user detail by mail id in drupal 8. As per drupal syntax first we have to add user library for classes then we will user drupal load by mail function that is "user_load_by_mail()".
$check_user = user_load_by_mail($mailid);
if (!empty($check_user)) {
$uid = $check_user->id();
$user_detail = \Drupal\user\Entity\User::load($uid);
$user_id= $user_detail->get('uid')->value;
$user_roles = $user_detail->getRoles();
$user_status = $user_detail->isActive();
$user_name = $user_detail->getUsername();
$user_body = $user_detail->get('body')->value;
$user_email = $user_detail->get('mail')->value;
$user_created_time = $user_detail->created->value;
$user_field = $user_detail->get('field_machine_name')->value;
$user_loggedin_check = $user_detail ->login->value; // that will return 1 or 0
if ($user_detail->login->value != 0) {
$first_login_data = date('Y-m-d H:i:s', $user_detail->login->value);
} else {
$first_login_data = 'never';
}
}
Note: If have any suggestions or issue regarding 'User load by mail in drupal 8' then you can ask by comments.
$check_user = user_load_by_mail($mailid);
if (!empty($check_user)) {
$uid = $check_user->id();
$user_detail = \Drupal\user\Entity\User::load($uid);
$user_id= $user_detail->get('uid')->value;
$user_roles = $user_detail->getRoles();
$user_status = $user_detail->isActive();
$user_name = $user_detail->getUsername();
$user_body = $user_detail->get('body')->value;
$user_email = $user_detail->get('mail')->value;
$user_created_time = $user_detail->created->value;
$user_field = $user_detail->get('field_machine_name')->value;
$user_loggedin_check = $user_detail ->login->value; // that will return 1 or 0
if ($user_detail->login->value != 0) {
$first_login_data = date('Y-m-d H:i:s', $user_detail->login->value);
} else {
$first_login_data = 'never';
}
}
Note: If have any suggestions or issue regarding 'User load by mail in drupal 8' then you can ask by comments.