D8 - show view in comments depending on user role
There is many ways to do it, but the simplest way is to check if user is admin or has exact role.. 

global $user;
   if ( !in_array('administrator', $user-&gt;roles) ) {
     ... do something ...
   }

OR

if( $user-&gt;uid !== 1 ){
  ... do something ...
}


OR

path_is_admin(current_path())