I have a content type 1 with user reference field and node reference field and content type 2 with user reference field.
Now when you fill those reference fields in type 1, and save, the referenced user is added to a user reference field in the referred node(content type 2).
Now, content access module should give permission for the referenced user to access the node(type 2) his name just got added to(in type 1)(i know, it's confusing).
The problem is, that it does not work, for some reason the permissions are not updated(possibly because i use node save and not drupal_execute when adding the user to node of type 2).
However, if i then go to the referenced node and resave it, the user gets the permissions..
so the QUESTION:
Can i make rules module to re-save the node that is being referenced in node reference field?
Thank you and sorry for confusing explanation! :)
Comments
Comment #1
itangalo commentedI think I know exactly which problem you are refering to -- you're using Node Access Node Reference and Node Access User Reference, right?
I've solved this problem myself in the following way:
1) Create a View that lists all the content that should be resaved, based on an argument input. (Let's call the argument nid1.)
2) Turn the View into a VBO view, and enable the action 'Save node' (or what it's called).
3) Call the VBO from Rules, after the actions that needs resaving has been performed.
The last step could be tricky. I've written a blog that might help you get through it: http://nodeone.se/blogg/johan-falk/make-rules-dance-with-views-bulk-oper...
Good luck!
//Johan Falk, NodeOne, Sweden
PS: I'm not maintaining the Rules module, just helping with support questions. You are welcome to ask more questions at http://groups.drupal.org/rules
Comment #2
bfr commentedThank you, i have never used VBO but i will give this a try!
Comment #3
Stomper commentedCan VBO and rules be used to resave nodes of a certain content type? I have a content type with nid token appended in the title using autonodetitles. Nid is only created after the initial save, so the node must be resaved twice inorder for the nid to appear.
I'd like to automate this process, perhaps with a cron run or something similar.
Suggestions?
Comment #4
itangalo commented@Stomper: Yes it can!
There is an action "save node" (or possibly "save content") that you can call from VBO. If you can build a view that lists all the nodes you want to save, then you can call it from Rules.
However, it is probably a better idea to use a triggered rule that acts when new nodes of the relevant type has been saved, and force a re-save.
Good luck!
//Johan Falk, NodeOne, Sweden
PS: I'm not maintaining the Rules module, just helping with support questions. You are welcome to ask more questions at http://groups.drupal.org/rules
Comment #5
Stomper commentedThanks for the tip, and explanation of VBO. I always wondered how you were supposed to use it, now I understand that you have to create views of the content you want to apply VBO to. Makes so much sense.
You wouldn't happen to know what I'd need to do to create a re-save rule?
Thanks again
Comment #6
itangalo commentedTo create a re-save rule, all you need is a rule triggering on new content saved, possibly conditions to limit to selected content types, and then there is an action available for saving the content again.
There's a pretty good screencast series on Rules in the link below -- it explains the VBO + Rules and a lot of more stuff.
Good luck!
//Johan Falk
**
Learn Drupal with Nodeone! Drupal 7 introduction | The Views module | Drupal learning curve | Rules for Drupal 6 | Theming Drupal 6
Comment #7
Stomper commentedIn the processing of watching the screencasts, but will a re-save rule require PHP or is it simple matter of setting options in the UI? I am no PHP programmer, so if it is necessary, code snippets would be appreciated.
Comment #8
Stomper commentedI think I have figured it out. The videos really helped. Quite straight forward.
Create a new triggered rule, call it something like "create node auto resave"
The trigger will be "save new content"
To apply the rule to only certain content types, add a "condition" and select the types you want to apply it to.
The action will be "save a content"
Need to test it, but is this the approach I should be taking?
Comment #10
Stomper commentedDoesn't seem to work as advertised. When does saving occur when used in a rule? After a cron run?
In my case, it takes several saves in order to get the title correct. The first content type has a nid in the title - requires one resave. The second content type references the first content type and displays the referenced node's title in its title along with the second content types nid. Basically, if the first content type is not saved correctly, than the referenced nid will require additional resaves to make it work.
Suggestions for this?
Also see this issue seeking resave options built into autonodetitle module, support it: http://drupal.org/node/1130694
Comment #11
itangalo commentedHm, it seems that it is working "as designed", but it is a bit tricky in your case.
If you want to have a title of a referenced node in the title, then you must make sure that the referenced node has the title you want first (or be forced to set the title again later on – as you seem to be doing now).
Not much more help I can give here, I'm afraid.
Comment #12
Stomper commentedRight, as long as I can assure the referenced node's title is correct, the referencing node shouldn't be an issue. The only possible issue is that the referencing node also has its own nid token in its auto nodetitle.
Is there any triggered rule that can prevent the creation of referencing nodes until the referenced node has been resaved twice?
Comment #13
itangalo commentedYou could always add the node creation rules in the same rule that re-saves the first node – but after this has occured. I would put it all in a rule set and call the entire rule set, to prevent cluttering a triggered rule.
Comment #15
Stomper commentedI am not sure if my rule is working, is there a way I check it. I just want to check that my node is being saved again after it is initially created.
Also, is there a rule to "update automatic nodetitles"? I see the option on the "content" administration page.
Comment #16
itangalo commented@stomper: As far as I know, automatic nodetitles are updated as soon as you resave the node – thus the "save node" action should work for this. Cheers!