I posted this in the Rules group, and someone suggested coming here with this question. Is there a way to prevent node creation via Rules? I want to be able to prevent someone from creating node if certain conditions are true.

Right now, the best idea I've had for this is to create a special-purpose role that allows creation of my node types, and grant or remove that role via rules, but this feels clunky and really pollutes the admin/user/permissions page (since I need to do this for several node types).

Is there another way to do this? If not, is it in the roadmap?

CommentFileSizeAuthor
#14 rules-400334.patch1.9 KBklausi
#12 rules-400334.patch1.88 KBklausi

Comments

mitchell’s picture

Component: Rules Core » Rules Engine

Is there another way to do this? If not, is it in the roadmap?

Rules is so generalized that the main task in implementing this on your site is not by adding a special feature to rules but rather applying your imagination. Coincidentally, that's the part I like most about Drupal.

  • Bumping users in and out of a role (and providing proper notifications so they know what's going on) is one way, but I agree that that's quite a bit of work.

The current userpoints_rules.module has a userpoints_action_grant_points function, but I'm not sure if that can award negative points. If you could check into that, that might help in exploring this further.

Best of luck!

Charlie Sibbach’s picture

I just confirmed that it does allow you to award negative points, but only into the default ("uncategorized") tally. However, without a condition like you mention above (checking for userpoints), this isn't much better than the Nodes and Comments system already in place (which lets you assign a reward to different node types).

As to using your imagination, I agree, that is one of the most rewarding parts of Drupal. Between Rules and Views, I stay quite amused.

mitchell’s picture

New opinion: if you just want to put a true/false next to a user for a certain permission, then use a non-global Flag. It's not all that different from roles or userpoints, but it's simple true/false, and it's a really good API with really tight #298109: Rules integration.

amitaibu’s picture

Status: Active » Fixed

You can't prevent a node creation with Rules, but you can create a rule that will delete a newly created node.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

mmilo’s picture

Version: 6.x-1.0-beta5 » 6.x-1.x-dev
Status: Closed (fixed) » Active

Sorry, this seems like a silly bump.

I can't find how to delete a newly created node - it isn't in the list of actions. I'm using the latest dev version. This wouldn't be due to the fact that my event is 'After saving new content' is it?

Thanks!

fago’s picture

hm, I think there is no action for deleting nodes yet.

mmilo’s picture

Are there any plans to have an action for deleting nodes / prevent the creation of a node?

fago’s picture

I do not have any plans, but I'd add an action for deleting content. Just roll a patch.

mitchell’s picture

Title: Prevent Node Creation with Rules » Action: delete node
Category: support » feature

Changing to feature request.

klausi’s picture

Assigned: Unassigned » klausi
Issue tags: +gsoc:rulesmonkey

Taking over.

klausi’s picture

Status: Active » Needs review
StatusFileSize
new1.88 KB

Patch is attached.

amitaibu’s picture

Minor issues:

+ * We cannot use node_delete() because it does access checks and ouput.

ouput -> output. Maybe worth adding @see node_delete()

+ * Action "Delete content" - Label callback

Label -> label.

klausi’s picture

StatusFileSize
new1.9 KB

Good idea, fixed.

fago’s picture

Assigned: klausi » Unassigned
Status: Needs review » Fixed

thanks, committed. :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

v-a-1’s picture

This is in response to [amitaibu] above

Thats incorrect.

You can. Its really simple too.

Create rule of type "content is going to be saved"

Add condition "if content type is xxx"
And whatever other condition you require to return true or false.

Add action "system page redirect" and set configuration to redirect to the same page.
Set configuration of above action to "immediately issue redirect".
This will stop the process of node creation in its tracks and send the user back to the node creation page.

It is generally required that you issue an error notice to the user.
You can do this by adding a "set configurable system message" action BEFORE the page redirect action.

Hope this helps.