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
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

ghankstef - May 23, 2007 - 19:28

Try this

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

#2

jrglasgow - May 13, 2008 - 02:24
Status:active» active (needs more info)

did this take care of your problem?

#3

newdru - May 14, 2008 - 14:01

yes

#4

jrglasgow - May 14, 2008 - 15:24
Status:active (needs more info)» fixed

#5

Anonymous (not verified) - May 28, 2008 - 15:31
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.