In this video, we will create a rule that will remove all “Offensive” flags from a node when a Content Moderator updates or edits the content.

Install Modules

Enable Modules

  • Go to "Modules" (admin/modules) and enable:
    • Entity API
    • Entity tokens
    • Rules
    • Rules UI
  • (Save Configuration)

Before we begin, I’m going to create a new role “Content Moderator”.

  • Go to “People => Permissions => Roles” (admin/people/permissions/roles)
  • Name: Content Moderator
  • (Add role)

Add a Rule

  • Go to “Configuration => Workflow => Rules” (admin/config/workflow/rules)
  • Click "Add new rule"
    • Name: Remove offensive flag when edited by content moderator
    • React on event: After updating existing content
  • (Save)

Add a condition

Now, we’ll add a condition that makes sure the current user has the role “Content Moderator”. (In this case, I don’t want to choose “Administrator” because it will conflict with the next Rule we are going to create. I’ll explain that more at the end of that video.)

  • Click "Add condition"
    • Select the condition to add: User has role(s)
    • Click "Continue"
    • User
      • Data Selector: site:current-user
    • Roles
      • Value: Content Moderator
  • (Save)

Add an action

In order to remove the flag for all users, we need to get a list of all users who have flagged the node.

  • Click "add action"
  • Action to add: Fetch users who have flagged a node
    • Flag: Flag as offensive
  • (Save)

Now we’ll add a loop that our “unflag” action will cycle through.

  • Click "add loop"
  • (Continue)

Now let's add the “Unflag a node” action to the loop

  • Click "Add action" under operations for loop
  • Action to add: Unflag a node
    • Flag: Flag as offensive
    • User on whose behalf to flag: list-item (This is the list we fetched in the first action.)
    • [x] Skip permission check (You can set your permissions to allow users to flag content, but not unflag it. If you do that, leaving this unchecked, will not allow you to unflag the content on the user’s behalf. If checked, you can unflag on their behalf even if they could not unflag on their own.)
  • (Save)

To check this rule, let's edit one of the articles that is flagged as offensive

  • Go to the “Offensive Content” page
  • Click "Edit" next to an article you’d like to edit
  • Edit the body
  • (Save)

At this point, if I edit an article, nothing will happen because I do not have the “Content Moderator” role. I’ll add that to myself now.

After updating this content, the "Remove offensive flag" rule will be triggered and will unflag the node as offensive content

Let's check it out, go to offensive content and see that the article is no longer in the list of offensive content.

This works great, but sometimes, you can’t get around to editing content as frequently as you need. In this case, you might prefer that the offensive content not stay published on your site if it has been flagged a certain number of times. In the next video, we will create a Rule that will automatically unpublish content that has been flagged as offensive five times so that if we can’t get to it right away, at least it won’t be offending more site visitors.