When I use Rules to password protect a node, this rule only works when it reacts on the event "Before node is created", and not on "After saving new content". So it seems the action "Password protect node" can only be used when a new node is created, not on existing nodes.

Comments

izus’s picture

Status: Active » Closed (works as designed)

hi,
as tested in https://www.drupal.org/node/2371613#comment-9387241
it is possible to do this on existing node when editing per exemple

sportel’s picture

Thanks for your response.
With https://www.drupal.org/node/2371613#comment-9387241, I can get it to work. But I'm trying to get to this:

I'm using Drupal Commerce for a shop (I hope you know how Commerce works, or else this probably won't make much sense to you). I'm using rules to automatically create a Product Display when I create a product. I added a field "password" to the product-type. When a password is entered when I create a product, that password has to be used to password-protect the Product Display.
I don't know how to fit the password part to my rule. This is how my rule looks now:

EVENT:
After saving a new commerce product
ACTIONS:
Create a new entity (entity type=node, content type=product_display)
Set a data value (data=productdisplay-created:field_product_reference, value=commerce-product)
Safe entity (entity=product_display-created)

I hope you can help?

Thanks,

Mike.

sportel’s picture

When I create a new rule that react on the event: Before saving content, with the action to set the password (test) on a node of type product_display, I get this error (when saving a new product):

Notice: Undefined property: stdClass::$nid in auto_entitylabel_set_title() (line 230 of /drupal/sites/all/modules/auto_entitylabel/auto_entitylabel.module).
Notice: Undefined property: stdClass::$protected_node_show_title in _protected_node_save() (line 848 of /drupal/sites/all/modules/protected_node/protected_node.module).
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'protected_node_show_title' cannot be null: INSERT INTO {protected_nodes} (protected_node_is_protected, protected_node_passwd, protected_node_show_title, nid, protected_node_emails, protected_node_hint) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => a94a8fe5ccb19ba61c4c0873d391e987982fbbd3 [:db_insert_placeholder_2] => [:db_insert_placeholder_3] => 86 [:db_insert_placeholder_4] => [:db_insert_placeholder_5] => ) in _protected_node_save() (line 853 of /drupal/sites/all/modules/protected_node/protected_node.module).

First I assumed it was because of the Auto Entity Label module (hence my other issue), but now it looks like the rule is in fact trying to set the password (test) but can't set it because it has no value for the 'protected_node_show_title' field in the database. Well, that's what I make of this error, but maybe I'm wrong.

sportel’s picture

Status: Closed (works as designed) » Active

Not sure if the title is still accurate, but I think the issue remains.

grimreaper’s picture

Assigned: Unassigned » grimreaper

I reproduce the error.

grimreaper’s picture

Status: Active » Needs review
StatusFileSize
new1.43 KB

I add a boolean in the password protect action so you can set the proerty protected_node_show_title.

I wanted this boolean to appear as a checkbox but I have not find how to easily do it. and I prefer going to another issue.

grimreaper’s picture

Hi sportel,

Did you test the patch and did it solve your issue ?

grimreaper’s picture

I add an automated test to rules extension.

Unfortunately I can't make it extends ProtectedNodeBaseTestCase.

  • Grimreaper committed dfe4bb4 on 7.x-1.x
    Issue #2371589 by Grimreaper, sportel, izus: Can't use Rules to password...
grimreaper’s picture

Status: Needs review » Fixed

Last patch merged.

Status: Fixed » Closed (fixed)

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

grimreaper’s picture

Assigned: grimreaper » Unassigned