1

I need to lock all English nodes from editing because translators sometimes change English nodes by mistake instead of creating translations for them.

Can it be done with Rules?

I guess it might work with the Rules Condition that uses a data comparison node:language equals English.

What Rules Action can be used here?

1

For the event, "a node is updated", use the action "set data value".. Unchanged node's body > Changed node's body and set a site message explaining that the translation wasn't saved.

I'd also make the rule only apply to the translator role.

| improve this answer | |
  • Will this work if there are more fields on that Content type besides Body? I couldn't find any option with the way you worded it, can you be more specific? – prkos Nov 17 '15 at 20:50
  • Yeah, you need to add "Entity has field" conditions for each field you want to use in actions. – Niall Murphy Nov 18 '15 at 0:27
  • I have a lot of content types and some of them with a lot of fields (more than 30) so it's not very convenient to check for all the details. Is there a way to just prevent node from being saved without checking for changes? Something like the Edit permission but only for English nodes. – prkos Nov 18 '15 at 11:00
0
  • Add event "when node is updated"
  • Add condition "if it has field language" AND "data compression value = English "
  • Add action "Add redirection of node page or you can show message on site "
| improve this answer | |
  • I tried event "Before saving content", Condition Data comparison Selected data: node:language equals English, and action Page redirect and Show a message on the site, but neither of those actions prevents node from being saved. The redirect works, and the message is shown after hitting Save button, but the changes still get saved. – prkos Nov 17 '15 at 20:53
0

Yes this is perfectly possible via the Rules module. Some more details about how to actually do so:

  • Rules Event: Drupal is initializing
  • Rules Condition (both must be true):
    • current path matches the pattern of editing a node.
    • check if the language of the node is English.
  • Rules Action:
    • perform an appropriate redirect (to whatever path that fits your needs).
    • set a Drupal message (to indicate such edits are not allowed).

For an example of a rule (in Rules export format) that you could use as a starting point, have a look at the answer to "Is there a way to restrict some pages like node/add, /user/login and more?".

Ps: I'm assuming this question is about D7.

| improve this answer | |
  • Thank you! I seem to have been successful with the path regex condition (I ended up with ^(node.\d*.edit)), but now I'm having trouble with the "current page content is in English" Condition, it doesn't work when using Data comparison in "Drupal is initializing" (even without the path condition). I was only able to make it work in "Before saving content" event. Any tips how to check for English content in this context? – prkos Mar 29 '17 at 0:52

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.