Rule to delete other node of same type before saving content I have designed one content type which can be created by registered users via "Form Block" Module. I am now trying to create a rule which will allow each user to only have one existing node of that content type. If they decide to create a node of that content type again, the previous node should be deleted.

I'm having trouble with the rule that would accomplish this. There are no errors, but nothing appears to be being deleted.

Event =

Before saving content


Conditions =

Content is of type (Parameter: Content: [node], Content types: NeuroTrans pt1)

Data comparison (Parameter: Data to compare: [node:author:uid], Data value: [site:current-user:uid]) 


Action =

Delete entity (Parameter: Entity: [node])


Here's an export of the rule that I have created:

{ "rules_delete_previous_neuro_pt1" : {
"LABEL" : "Delete current user\u0027s previous NeuroTrans pt1",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules" ],
"ON" : [ "node_presave" ],
"IF" : [
  { "node_is_of_type" : {
      "node" : [ "node" ],
      "type" : { "value" : { "neurotrans_pt1" : "neurotrans_pt1" } }
    }
  },
  { "data_is" : { "data" : [ "node:author:uid" ], "value" : [ "site:current-user:uid" ] } }
],
"DO" : [ { "entity_delete" : { "data" : [ "node" ] } } ]


}
}

**Using the "code" entry mode for this post doesn't appear to preserve the formatting quite perfectly.

Any guidance would be much appreciated. Thanks!!
Daniel,

What I think is happening is that you're trying to delete the actual node that the user is about to save (it hasn't been saved yet)!

It doesn't look like you're finding the user's PREVIOUS node to delete first, you're just trying to work with the current one.  :-)

Of course - since this current node hasn't even been saved yet (your event is prior to saving), there is nothing to be deleted.

The rule will have to be more complicated, with your finding an existing node by the current user first... 

Hope this helps.