Prepopulate from link in content only visible to users tagged within that content I have two content types, Parent and Child. Parent contains a list of tagged users which may create Child. Child contains the tag of the Parent.

On the Parent page I need a link, which is only visible to people tagged in it, to create a new Child with the Parent already tagged in it.

I know I need to use something like Entity Reference Prepopulate but my problem is that I can't figure out how to make the link.

This seems like it should be a simple thing to do but I can't for the life of me figure out how!

The requirement is that this should only use the UI and without editing any .php files as there is no guarantee that other devs will be able to code and allows easy visual recognition of what has changed.

Any advice would be greatly appreciated.
So here is how to do it.


Install and activate Entity Reference Prepopulate and enable it within the Entity Reference of Parents field in Child. You can now populate that field by  example.com/node/add/child?field_parents=[parent nid].
Install and activate Views PHP.
Create a new View without any pages or blocks called "Create new Child"
Click "+Add" and select "Content Pane"
Apply the following settings:

Filter critera

Content: Published (Yes)
Content: Type (= Parent)

Pane settings

Link to view: Yes
Argument input: From context>Node Content ID

Contextual filters (under advanced)

Content: Nid


Set Format - Show: Fields and then add a field - Global: PHP
In the configuration for Global: PHP, in the Output code section write:
&lt;?php print '&lt;a href="http://example.com/node/add/child?field_parent=' . (string)$data-&gt;nid . '"&gt;Create new child&lt;/a&gt;'; ?&gt;. (N.B. You need title field/NID field added as well for the %data-&gt;nid to work, hide it if you wish)
Add a Global: PHP in "Filter Criteria" and add the following code

$uid = $GLOBALS["user"]-&gt;uid;
$node = node_load($data-&gt;nid);
$info = field_get_items('node',$node,'field_users');
$uids = array();
foreach($info as $user)
{
$uids[] = $user['target_id'];
}
return in_array($uid, $uids) ? FALSE : TRUE;  
Save everything. In in Pages now, you can add this into Panels via "View Panes".