1

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 Apr 16 '15 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 Apr 16 '15 at 1:20
  • It's easier to use custom template. Are you using just one content type? – Danz Apr 16 '15 at 1:27
  • Yes. I am assuming I would have to add some custom PHP into node--[type|nodeid].tpl.php? – Brandon Apr 16 '15 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 Apr 16 '15 at 1:39
2

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, privacy policy and cookie policy

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