0

I have a node type that represents a phone call. The user can schedule a call, then record notes about the call. I want to give the user the ability to deleted these call nodes, but only if the call has not happened yet. Is there a way to review a call node (using rules) the cancel the delete operation if specific criteria fail?

This could also be used to make an "Are you sure?" option for node deletes.

1
  • This comment regards deleting nodes in general, it isn't rules specific: Once node_delete() has been called there is no stopping it. There are no hooks or anything that can intervene. So wherever you are that is calling node_delete() you must stop it before that is called. For example if a form submission deletes a node you have to stop it before that submit handler calls the delete function. I'm not sure whether or not rules can intervene with a form submission in this manner.
    – rooby
    Jun 11, 2014 at 12:26

1 Answer 1

1

You should be able to do this via the conditions field in the rules module. Unsure how to create an 'are you sure' option, but you could certainly stop them from doing it with rules.

There might be better solutions, but here's what I'd do if I wanted to achieve what you are doing.

Install Flags and Rules module. Create flag to appear on Content Type 'Phone call' called 'Delete this call'.

In rules create two rules. One called Delete call, the other called 'display message about unable to delete call'.

First rule:

Triggered on action - node is flagged Conditions - Entity has field call date/time (whatever the field is called) - Data comparison - select the date/time field, then is greater than +1 minute.

Then action - unpublish content

For the second rule do the same but change second condition to less than - 1 minute. Then as the action do 'display message on the site' and select message as 'Unable to delete calls that have passed'.

That should work.

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.