How make $user->uid available to theme
newdru - February 26, 2007 - 01:41
| Project: | Content Templates (Contemplate) |
| Version: | 5.x-1.1 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
I want to only display a cck field if the user is NOT anonymous..
I tried using $user->uid directly in my custom template 'node-events.tpl.php' for my 'events' custom content type but that did NOT work.
i've tried passing $user->uid into my cck custom template 'node-events.tpl.php' using _phptemplate_variables and that did NOT work either:
function _phptemplate_variables($hook, $vars) {
switch ($hook) {
case 'events':
$vars['user'] = $user->uid;
break;
}
return $vars;
}how can i access the uid of teh current user from withIN a cck content template (via contemplate or tpl.php file)..
thanks much

#1
Try this
global $user;if ($user->uid) {
// whatever you need to do with the user id if availalbe
}
#2
did this take care of your problem?
#3
yes
#4
#5
Automatically closed -- issue fixed for two weeks with no activity.