The Flag module is pretty robust, so maybe I am missing something. It has a lot of access features as to who can flag/unflag but I can't seem to find a way to prevent a user/role from being flagged.

Scenario: Creating a flag where all administrators posts should not be able to be flagged but "authenticated users" should be able to flag other content for other roles. All roles content should be flaggable except for administrators (or "premium users")

There doesn't seem to be a "if user is of role X, disable the ability to flag/unflag using FLAG NAME" permission or setting.

  • Are you using a custom template for your content type?
    – Danz
    Commented Apr 16, 2015 at 1:17
  • No. I was hoping it would be something that was done either by Flag itself or through a sub-module. Is the only way to accomplish this through custom templates?
    – Brandon
    Commented Apr 16, 2015 at 1:20
  • It's easier to use custom template. Are you using just one content type?
    – Danz
    Commented Apr 16, 2015 at 1:27
  • Yes. I am assuming I would have to add some custom PHP into node--[type|nodeid].tpl.php?
    – Brandon
    Commented Apr 16, 2015 at 1:32
  • Yes, if that is okay with you. either that or you create 2 content types. 1 for admin/premium and 1 for other roles but the template it easier.
    – Danz
    Commented Apr 16, 2015 at 1:39

1 Answer 1


Here is a sample code you could use for your custom template.

// Load the currently logged in user.
global $user;

// Check if the user has the 'standard' role.
if (in_array('standard', $user->roles)) {
  // enter the code to print your flag

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.