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

Comments

ghankstef’s picture

Try this

global $user;
if ($user->uid) {
  // whatever you need to do with the user id if availalbe
}
jrglasgow’s picture

Status: Active » Postponed (maintainer needs more info)

did this take care of your problem?

newdru’s picture

yes

jrglasgow’s picture

Status: Postponed (maintainer needs more info) » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.