By admin , 26 March, 2024 Get string link to user $attributes = [ 'title' => 'View user profile.', ]; $link = $test_user->toLink(NULL, 'canonical', ['attributes' => $attributes])->toString(); Tags user
By admin , 26 March, 2024 Get user (id) from URL $user = \Drupal::routeMatch()->getParameter('user'); Tags user routes
By admin , 1 March, 2023 If user has role $current_user = \Drupal::currentUser(); $roles = $current_user->getRoles(); if (in_array('editor', $roles, TRUE)) { // } Tags user roles