Hi. Thanks for a cool module.

I need to prepopulate a field with the current logged in user's Username when he or she clicks on a link. So I tried this in the href, but it didn't work:

/node/add/post?edit[field_post_author][und][0][nid]=$_GLOBALS['user']

It just put "$_GLOBALS['user']" in the field, rather than the user's name.

Any ideas?

Thanks!
Tim

Comments

autopoietic’s picture

$_GLOBALS[] is a PHP function, it will not be evaluated in the URL, and it would not generally be safe to evaluate PHP code that arrived from the query string.

The solution (probably too late for trgreen23 would be to generate the prepopulate link in its completed form prior to rendering it so that the nid is just a number:

/node/add/post?edit[field_post_author][und][0][nid]=23

This could be done in a block provided by your own module or in a custom block using the php filter, or using tokens if the link is to be provided by a view etc.