I have created a view in table format and added a field as global custom text field. I want to show this field to administrator only, not to other created roles. How can I do that?
1 Answer
you need to do something like this in global php field :
$uid = 1;
$user = \Drupal\user\Entity\User::load($uid);
$roles = $user->getRoles();
$v=$roles[1];
if($v == "administrator")
{
echo "your-content";
}
Global php field will be available as Replacement pattern add that variable in your custom text field.