CCK > user reference field > default value > php code to choose currently logged in user from the list
| Project: | User Referral |
| Version: | 5.x-1.x-dev |
| Component: | Miscellaneous |
| Category: | support request |
| Priority: | normal |
| Assigned: | mo_ |
| Status: | postponed (maintainer needs more info) |
Jump to:
Hello,
Thanks to everyone in this great community. I am new to Drupal and make my first steps in understanding.
So far I could figure out every solution with the infos I found here. But not in this case.
I use CCK and the USER REFERENCE modul/field. When I enter the configuration of that field in my content type I see the option 'Default Value' and the suboption to enter php code to define the default value.
That is exactly what I need (I think).
What code would I have to enter there to select by default the currently logged in user.
Can anybody help me with this code ? I have no clue about php
Below the PHP default value entry field there is the following hint:
"Advanced Usage Only: PHP code that returns a default value. Should not include
<?php
?>array(
0 => array('uid' => value for uid),
// You'll usually want to stop here. Provide more values
// if you want your 'default value' to be multi-valued :
1 => array('uid' => value for uid),
2 => ...
);
Using devel.module's 'devel load' tab on a story content page might help you figure out the expected format."
Thank you so much ... I hope I learn fast to be able to contribute back to the community soon ...

#1
This works:
global $user;
return array(0 => array ('uid' => $user->uid));
#2
And what about autofilling additional "profile_" -entries.
Example:
Registered user has profile information:
first name(profile_firstname)
last name(profile_lastname)
How can i make for example the first name a default field value?
Tried several approaches but the field stays empty :(