0

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!

2 Answers 2

1

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 ... }

OR

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

OR

path_is_admin(current_path())

0

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.

1
  • the problem is: how the view recognize the author (user) of the comment
    – lolhonk
    Commented Feb 21, 2018 at 11:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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