Hi,
Here's what I'm trying to do. Any help would be greatly appreciated!
Upon saving new content, set a user reference field with all of the users that belong to the group content's audience that have the administrator member role.
Use case: We're using organic groups to manage committees. Then, we create evaluation nodes of these committees. Because the committee (group) membership changes, we want to save the group administrators to a user reference field within the evaluation node.
Here's what I'm trying to do with out the check on group member's user role.
Rule
Event:
After saving new content
Condition:
Content is of Type X
Actions:
Get group members from group audience
Loop on group_members as list-item
=>Add an item to a list: Selected List is node:field-evaluation-members Data Selector: list-item
My other ideas are:
1) Call a separate component from within the loop to check user's role, but I'm unsure how to pass the loop list-item to the component.
2) Set data value with UID of list-item:uid or something similar.
Thanks, Jason.
Comments
VBO
If you can make a view that selects all the relevant users, then you can use that view in Rules to load the results as a list of users.
Once you have that list, simply use the "set a data value" and cram in the entire list as the field value. (No need to loop and add them one by one – multiple-value fields accept lists as new values.)
Some more information on how to use VBO and Rules together is found here: http://dev.nodeone.se/en/using-vbo-to-load-list-of-objects-into-rules
Good luck!
//Johan Falk, Sweden
RE: VBO
Hi Johan,
Thanks for the response. My first attempt to dig around views to filter organic group members based on organic group user role was fruitless. I'll need to investigate this further.
However, I tried a simpler setup to prove the "set a data value" using a list.
I tried
Action: Get group members from group audience
Parameter: Group content: [node]
Provides variables: List of group members (group_members)
Action: Set a data value
Parameter: Data: [node:field-evaluation-members], Value: [group-members]
This approach returned an error on node save. Perhaps
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '77-0-all' for key 1: INSERT INTO {node_access} (nid, realm, gid, grant_view, grant_update, grant_delete) 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] => 77 [:db_insert_placeholder_1] => all [:db_insert_placeholder_2] => 0 [:db_insert_placeholder_3] => 1 [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => 0 ) in node_access_write_grants() (line 3392 of node.module
I then tried this alternative using just the UIDs seperated by commas. This produced the same error.
Action: Set a data value
Parameter: Data: [node:field-evaluation-members], Value: 35, 45, 39
I will try returning a list using a view, and then report back. I'm assuming I would use the Action: Load a list of entities from a VBO View.
Jason.
Did you find any solution ?
Did you find any solution ?
I want to do the same thing but there is a twist
Before saving a comment i want to display list of all the group members belonging to the group who are active in a CCK selectlist field created in the comment field.
Then on saving the comment i wish the comment to be refereed to User..........Any clues to how can i achieve this ? ( i am new to drupal and web development stuff)
Thanks in advance for the help......
http://www.propertysimplified.in/
http://dev.nodeone.se/en/usin
http://dev.nodeone.se/en/using-references-with-views-relationships .....
http://dev.nodeone.se/en/send-comment-notifications-to-authors ....
check these links out ......somewhat related to your solution ...
http://www.propertysimplified.in/
more parameters in VBO
Hi, I have a component that uses a VBO list of groups, filters the groups with two arguments, loops, and basically subscribes the selected user (in another view of users) to the groups previously filtered by those arguments.
Now my idea is to add a parameter so that the component doesn't just subscribe the user to all those groups but that also lets the current (active) user select what exact groups that passive user will become member of.
I tried adding a new parameter, but an old-looking field asks us to enter the NUMBER (?) of the group (one group?) that we want to select.
1st: don't know numbers (gid?) of any group
2nd: I want a nice little table with checkboxes to chose from (for example)
3rd: I'm obviusly missing something of knowledge when I reach this point.
Anyone wants to help?
thanks so much
PS: Since I bought the book of Mr. Falk i'm enjoying drupal x10. Thanks Johan for everything, i've watched your screencasts more than any of my favourite movies. :)
www.theverylittleagency.com
I'm also searching for such a
I'm also searching for such a solution... :(
Current logged in user should
add/ remove selected user
from own groups.
A simple nice UI with checkboxes would be really great. Do same tests with rules or vbo but without success... Any idea how to to get it work?
Thanks!
Any Updates?
Hi - I am working on a similar issue: moving a list of users from one user reference field to another during node save/update, and I would like to enforce uniqueness using the add item to list action. Has anyone addressed this using either a VBO approach or a more 'typical' rules solution? I have only run into the 'PDOException: SQLSTATE[23000]: Integrity constraint violation...' type errors so far using rules.
Thank you.
Did any of you find a
Did any of you find a workaround for the error 'PDOException: SQLSTATE[23000]: Integrity constraint violation
which appears when trying to set the group audience in Rules?
cannot perform "Add an item
cannot perform "Add an item to list" with latest rules 7.x-2.8+2-dev
issue:
https://www.drupal.org/project/rules/issues/2947392