how i have to set up a view with Drupal 8 to show a field in the comments when the user_role is NOT "admin".

im not sure what kind of relationship and contextfilter i need to to this?

background: i want to show a label under the user_image of the comments Thanks for help!


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->roles) ) { ... do something ... }


if( $user->uid !== 1 ){
  ... do something ...




I don't have all of the answer. However I think you need to create a user view instead of a content view. That might be the key to solving it.

  • the problem is: how the view recognize the author (user) of the comment – lolhonk Feb 21 '18 at 11:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.