I am making a site where users can create clones of nodes. These clones will appear, using views, in place of the original node depending on the users role and hopfully a value in the users profile.
The user role is easy but I can't seem to limit the view so that the cloned nodes only show if the author of the node shares a common profile value with the viewer.

I have cck content profile node called client details with a cck text field called 'storename'

If the author of a cloned node has a value for this 'storename' field: Example = 'shop B',
I want everyone who has the value 'shop b' in their storename field to be able to see the clone using views.

I figure this will be a PHP argument or something to do with content profile and relationships.

I can get all clones to turn up on the right page but I can't filter them as described.

Sorry if this is duplicate.

Comments

BIGREDPAUL’s picture

I ended up using rules to save information from the user and the cloned node into hidden fields.
One that saved the original node ID into a field when ever you create content of that type unless the url ends with Clone. This means that when you create the clone the original node ID is kept in the field.
That made it easy to use a views argument that took the node ID to make the clone appear along side the original when a user visits the original page.
The second rule trick was to compute a field that saved the "store name" from the profile of the user only when saving clone content.
This meant that there was a hidden field on the clone that stored the info so I could then use another views argument to restrict the view to only people with the same store name in their profile.
I am no good with PHP but I managed to find a snippet (can't remember where) that returns the store name of the current logged in user as the argument.

 global $user;

profile_load_profile($user);

return $user->profile_store_name;