1
nkarkine
How to retreive user name???
  • 2007/7/19 18:32

  • nkarkine

  • Just popping in

  • Posts: 3

  • Since: 2007/3/14


Hi,

I am trying to catch the user name (login) in a module i made myself.
I can do it like this:

$loggedInAs = $xoopsUser->getVar('uname');
print ("User:");
print $loggedInAs;

but if the user is not logged in he will be thrown into the default module without any of the XOOPS frameworks.

can anyone help me?

2
zyspec
Re: How to retreive user name???
  • 2007/7/19 19:40

  • zyspec

  • Module Developer

  • Posts: 1095

  • Since: 2004/9/21


I'm not sure I completely understand what you're asking but what I believe you're asking is how to determine if a user is logged in and then redirect them somewhere if they aren't.... If that's what you're looking for then try:
if (!is_object($xoopsUser)) {
  
redirect_header('page_4_anon_user.php',3,'Redirected Message Here');
  exit();
}

3
nkarkine
Re: How to retreive user name???
  • 2007/7/19 20:22

  • nkarkine

  • Just popping in

  • Posts: 3

  • Since: 2007/3/14


sorry i was a bit unclear. it is kind of the other way around.

basically i just want to display the user name of the logged in user, or just as blank if he is not logged in.

this because i have dynamic functionality based on who is logged in in my module. if he is not logged in he will get the default functionality.

but i got it working with your help - thanks!!!

like this:

if (!is_object($xoopsUser)) {
// do nothing
}
else {
$loggedInAs = $xoopsUser->getVar('uname');
print ("User:");
print $loggedInAs;
}


Login

Who's Online

274 user(s) are online (237 user(s) are browsing Support Forums)


Members: 0


Guests: 274


more...

Donat-O-Meter

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

Latest GitHub Commits