User related methods in DRUPAL 8

22
April

User related methods in DRUPAL 8
By: Anonymous | Published On: Wed, 04/22/2020 - 22:13

Get user role of current loggedin user

$user_roles = \Drupal::currentUser()->getRoles();

Get user detail of curent loggedin user

$user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());
user_delete(uid);

$user_roles = \Drupal::currentUser()->getRoles();
$user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());
$uid = $user->get('uid')->value;	

Comments

Need Help ?