This website can use cookies to improve the user experience

This website can use cookies to improve the user experience and to provide certain services and functions to users. Cookies contain small amounts of information (such as login information and user preferences) and will be stored on your device.

Enable All Cookies Privacy Policy

test for username?


avatar
Rushian 0
From: -
test for username?

How can I test for a certain username (or ID) and then print some HTML code?

I want to print a few special links if I'm logged on.

Psedo-code:
if $user_name = "Rushian" $html="You are the webmaster!"

Notice

This topic is archived. New comments cannot be posted and votes cannot be cast.

Responses to this topic


1 Re: test for username?
avatar
OP 0
From: -
test for username?

Lol, yes, that fixed it. I've now added a few 'admin only' links to the main menu.. Thank you.
1 Re: test for username?
avatar
Administrator
1340
From: Vienna, Austria
test for username?

Maybe because the cookie is called esselbachst and not ESSELBACH_ST. Sorry Hushed Face
1 Re: test for username?
avatar
OP 0
From: -
test for username?

Originally posted by Philipp:
Something like this should work:

$cookiedata = explode (":!:",  addslashes(base64_decode($_COOKIE["ESSELBACH_ST"])));

if ($cookiedata[0] == "Rushian") $html = "You are the webmaster!";

Err, wait. This isn't working for me.. Slightly Frowning Face

Nothing prints in the page where I inserted the $html var.. I tried both logged on and out.. I'm running 1.72c if it matters and running it from the site_header template..

Edit: As near as I can tell $cookiedata[0] is null... :x
1 Re: test for username?
avatar
OP 0
From: -
test for username?

Super!

Is there a list of global vars that I can insert into my templates? (Besides what's already in the template docs?) (Stuff like user data, page views, times, dates, number of items, etc..) I've tried snooping through some of the code, but when I try to output the vars (say, $mystats), nothing prints.
1 Re: test for username?
avatar
Administrator
1340
From: Vienna, Austria
test for username?

Something like this should work:

$cookiedata = explode (":!:",  addslashes(base64_decode($_COOKIE["ESSELBACH_ST"])));

if ($cookiedata[0] == "Rushian") $html = "You are the webmaster!";

Notice

This topic is archived. New comments cannot be posted and votes cannot be cast.