Tos Web Developer provides insights, tutorials, and advice around topics including content strategy, design, Drupal Development, Drupal Custom Module Development, Drupal 8 Custom themes, PHP, Server, Twig, and more

                       


 $user_id= \Drupal::currentUser()->id();  

Using you can get login user ID

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

Using user role you can get user role of login user

 $other_user_field = $user_id->get('field_name')->value;  

Using above field you can get other user field value in Drupal 8.

No comments:

Post a Comment

| Designed And Blog Post by www.toswebdeveloper.com