1
Erikmy
Request: Code to retrieve username of the user currently logged in
  • 2009/11/18 23:28

  • Erikmy

  • Just popping in

  • Posts: 13

  • Since: 2009/10/1


I'm trying to alter a module and need a function that retrieve the username of the user currently logged in.

I've tried reading a tutorial about module developement and looking at the code of userprofile.php, but I'm a pretty inexperienced coder and XOOPS is much more complicated than anything I've modified before.

This might belong in the Module developement section, but I think this might be pretty easy to figure out for some of you, so I'm posting here first.

So, anybody know the easiest way to do this?

(You don't have to explain how to build a module, just what code I need for this one thing.)


2
noo-b
Re: Request: Code to retrieve username of the user currently logged in
  • 2009/11/19 11:47

  • noo-b

  • Just can't stay away

  • Posts: 456

  • Since: 2007/10/23


eg
<{if $xoops_isuser}>Welcome <{$xoops_uname}>
.&
nbsp;<a href="<{$xoops_url}>/user.php">Your 
                 Account 
</a>&nbsp;|&nbsp;<a href="<{$xoops_url}>/user.php?op=logout">Logout</a>
 <{else}>
Welcome Guest. <a href="<{$xoops_url}>/register.php">Register</a> &nbsp;|&nbsp;<a href="<{$xoops_url}>/user.php">Sign In</a
                  <{/if}>


http://xoops-tips.com/modules/news/article.php?storyid=12

3
kaotik
Re: Request: Code to retrieve username of the user currently logged in
  • 2009/11/19 12:53

  • kaotik

  • Just can't stay away

  • Posts: 861

  • Since: 2004/2/19


are you looking to retrieve it in the smarty templates are a php page?
noo-b has already provided you with a smarty example.

4
trabis
Re: Request: Code to retrieve username of the user currently logged in
  • 2009/11/19 13:46

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


if (is_object($GLOBALS['xoopsUser'])) {
$name = $GLOBALS['xoopsUser']->getVar('uname');
}

5
Erikmy
Re: Request: Code to retrieve username of the user currently logged in
  • 2009/11/19 16:09

  • Erikmy

  • Just popping in

  • Posts: 13

  • Since: 2009/10/1


Thanks alot!
Wanted it as a variable like trabis wrote.

(Sorry if I'm not presenting the issue correctly. As I said, i'm pretty new to this. (I find it awesome, though!))

Login

Who's Online

242 user(s) are online (159 user(s) are browsing Support Forums)


Members: 0


Guests: 242


more...

Donat-O-Meter

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

Latest GitHub Commits