1
SERB-4-LIFE
displaying user name in php?

Hello, i am editing a module and i am editing the index file now i need to know why doesnt this work, if someone knows can you please tell me.

if ($xoops_isuser){
    echo 
"Hello <{$xoops_uname}>";
    }else{
        echo 
"Please register";
    }


Now i have realised that <{$xoops_uname}> doesnt work, it doesnt display the username i have also tried $xoops_uname and it still doesnt work.

But the other thing is ($xoops_isuser) this doesnt work, so it only displays the "else" code.

Can someone help me please, i dont know much about php so i am asking here.

2
Mithrandir
Re: displaying user name in php?

if ($xoopsUser) {
    echo 
"Hello ".$xoopsUser->getVar('uname');
}
else {
    echo 
"Please register";
}

<{$xoops_uname}> and <{$xoops_isuser}> are Smarty variables only available in themes and templates.
"When you can flatten entire cities at a whim, a tendency towards quiet reflection and seeing-things-from-the-other-fellow's-point-of-view is seldom necessary."

Cusix Software

3
SERB-4-LIFE
Re: displaying user name in php?

Ok thanks a lot, yeh i knew they were smarty variables but i still tried. But yeh thats what i am after thanks a lot.

4
SERB-4-LIFE
Re: displaying user name in php?

Hey i just tried this
if ($xoopsUser){
        echo 
"Cao! ".$xoopsUser->getVar('uname');
    }else{
        echo 
"Sistem bodovanja samo vazi sa registrovane clanove. Registrujte se basplatno <a href="<{$xoops_url}>/register.php">ovde.</a>";
    }


and it doesnt work it only displays the else part so thing the ($xoopsUser) part doesnt work

can some1 help

5
smdcom
Re: displaying user name in php?

try to put:

global $xoopsUser;

if (
$xoopsUser){
    echo 
"Cao! ".$xoopsUser->getVar('uname');
}else{
    echo 
"Sistem bodovanja samo vazi sa registrovane clanove. Registrujte se basplatno <a href="<{$xoops_url}>/register.php">ovde.</a>";
}

6
Mithrandir
Re: displaying user name in php?

Yeah, sorry - I always forget about the global scope
"When you can flatten entire cities at a whim, a tendency towards quiet reflection and seeing-things-from-the-other-fellow's-point-of-view is seldom necessary."

Cusix Software

Login

Who's Online

147 user(s) are online (104 user(s) are browsing Support Forums)


Members: 0


Guests: 147


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits