2

In my website I have 3 roles: user, tester and admin. When a user submits the content, tester will check and approve it.

As long as the content is not "approved", users can edit and delete their own content. But after the content is "Approved" (indicated via a field with value "approved"), users are not not allowed anymore to edit or delete their content.

How to do this with the Rules module based on roles?

0

Under permissions give the role ability to update only their own content. Then set a rule when node is published, author of role is set to another site user? That would be a quick implementation.

  • Thanks for your replay. Its work. i got an idea for something related my task. thanks – Raj.G Apr 28 '15 at 11:46
0

You can get this to work with the Rules module. The rule you'd need is something like so:

{ "rules_disallow_edit_of_approved_nodes" : {
    "LABEL" : "Disallow edit of approved nodes",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_update" : [] },
    "IF" : [
      { "NOT user_has_role" : {
          "account" : [ "site:current-user" ],
          "roles" : { "value" : { "6" : "6" } }
        }
      },
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_approval_status" } },
      { "data_is" : { "data" : [ "node:field-approval-status" ], "value" : "approved" } }
    ],
    "DO" : [
      { "drupal_message" : {
          "message" : "Sorry, edit is not allowed (admin status is approved).",
          "type" : "error"
        }
      },
      { "redirect" : { "url" : "no_access" } }
    ]
  }
}

To experiment with this rule in your own site, just copy the entire Rules code above, and paste it in a new Rule in your own site, created via the "Import" function. Then further edit/refine to make it fit in your own environment, e.g:

  • this rule assumes that the tester role has role id = 6 (change to whatever role id that fits).
  • the machine name (field_approval_status) and the field value (approved) of the field that contains the approval status.
  • adapt the "Sorry, ..." message to be shown, if needed.
  • the URL to redirect to.

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.