I have a code in comment.tpl as print $links

I want to show the link if only userid==1

I tried something like this but it did not work

 global $user;
            if ($userid == "1") print $links 

I would appreciate some feedback

Comments

mm167’s picture

try

$user->uid == 1

...

good luck.

halisemre’s picture

thanks this did the job

dainesj’s picture

Hi There,

I know this is an old post but just after a little help.

I am also trying to display a block to multiple userid's and using:

if ($user->uid == 1)

Question - how would I change this to add in multiple users:

i.e.

if ($user->uid == 1, 2, 3, 4, 5 etc)

Any help appreciated!

Regards
JD

ayesh’s picture

The easiest way, I think, is in_array().

//modify the array below so you don't have to make changes in the condition itself
$allowedto = array ("1", "2", "3", "4", "5", "1243912");
global $user;
if (in_array($user->uid, $allowedto)) {
// return true because you are going to use this for block visibility. Use print or other functions when using elsewhere. 
return TRUE;
}