Long story short, I installed Flag because Best Answer was not working properly. Is it possible to configure flags so that only the admin can flag something (aka an answer as being approved) but everyone can view the flag?

2 Answers 2


Try setup Flag as "global flag" and then in "Flag access" setup "Roles that may use this flag" check-boxes only for Admin.

If in this case flag will not be shown for other users - you need create script that get flag value for each node and display this info.

$flag = flag_get_flag(FLAG_NAME);
$node->flag_value = $flag->get_count($node->nid);

You can use the Rules module for this, especially by using the not commonly known/used Rules Action "Trim a flag", which looks like so:

enter image description here

Here is a rule (in Rules export format) that you could use to trim a flag, say with machine name best_answer:

{ "rules_limit_access_to_best_answer_flag" : {
    "LABEL" : "Limit access to best answer flag",
    "PLUGIN" : "reaction rule",
    "ACTIVE" : false,
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "flag" ],
    "ON" : { "flag_flagged_best_answer" : [] },
    "IF" : [
      { "NOT user_has_role" : { "account" : [ "flagging-user" ], "roles" : { "value" : { "3" : "3" } } } }
    "DO" : [
      { "flag_trim" : {
          "flag" : "best_answer",
          "flagging_user" : [ "flagging_user" ],
          "cutoff_size" : "0",
          "trim_newest" : "1",
          "permission_check" : "1"
      { "drupal_message" : {
          "message" : "Be aware: since you do not have the administrator role, your flagging-attempt has been ignored.",
          "type" : "warning"

After you adapt best_answer to the machine name of the flag you're using, simply use the Rules UI to import the above rule in your own site (and enable the rule afterwards).

Some more details to explain the magic in the above rule:

  • Rules Event = A node has been flagged (using the best_answer flag).
  • Rules Condition = The flagging user does not have role "administrator".
  • Rules Actions =
    • Trim the best_answer flag, with cut_off value equal to zero (which is the same as saying "Ignore any flags from the flagging user").
    • Set an appropriate warning message.

So with this approach, any user who has permission for the flag, will actually see the flag. But if they try to use the flag, it will be ignored unless they are an administrator.

Happy flagging with Rules!

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.