Page 1 of 1

Script to display username or name..

Posted: Fri Dec 19, 2008 9:38 am
by flazai
Hi guys,
Just asking whether u can tell me a session code or any script on how to display username at my custom page after logon at main page. I did a wrapper link in my Joomla!.

my Joomla! version is 1.5.

Thanks..

Re: Script to display username or name..

Posted: Sun Jan 11, 2009 7:54 am
by prateekshaweb
$user =& JFactory:;getUser();

echo $user->username;

you can create a module....and insert it in your page

Re: Script to display username or name..

Posted: Mon Jan 12, 2009 2:04 am
by flazai
Dear Prateeksha,

Thanks for your help..
:)

Re: Script to display username or name..

Posted: Tue Mar 03, 2009 5:05 am
by zacharyrs
I did just that.

I downloaded a php module that can display php code. I set that to a new userlocation and did the moduleposition command in joomla to be put inside an article. Here is the code I used:

Code: Select all

$user =& JFactory:;getUser();

echo $user->username;
And here is what is shown on the screen in joomla:
Welcome
$user =& JFactory:;getUser(); echo $user->username;
I also use a different approach and actually put in the php codes here:

Code: Select all

<?php
$user =& JFactory:;getUser();

echo $user->username;
?>
and this is what I get
Parse error: syntax error, unexpected ':', expecting T_PAAMAYIM_NEKUDOTAYIM in /home/p242rp0j/public_html/modules/mod_jumi/tmpl/default.php(12) : eval()'d code on line 2

Also the following code just produces a blank spot

Code: Select all

<?php echo $name->username; ?>
Any ideas what I am missing here?

Re: Script to display username or name..

Posted: Tue Mar 03, 2009 5:37 am
by prateekshaweb
yes...my mistake... there was a ; (semicolon) instead of a :colon near getUser();

try this
<?php
$user =& JFactory::getUser();

echo $user->username;
?>

Re: Script to display username or name..

Posted: Tue Mar 03, 2009 5:49 am
by zacharyrs
There is a line break above and below the actual username. IS there a formatting issue in the php code, or my module inside my article?

Re: Script to display username or name..

Posted: Wed Sep 23, 2009 1:01 pm
by ivan_mef
Hi!

My english is not so good, sorry.
I have question for you, for experts!

I have joomla 1.5 on hosting server, everithings worg great but now I make one upload php script and upload them to my server with static (public) IP adress (now i live in one student campus, admin geave me that adress). These two server separated!!! Upload script, when user upload file, send email to admin (me) with informations about file (filesize, extenzion, filename...). Problem is here: Only log in users have permisions for uploading files (upload page put in joomla with wrapper. When user login, upload page shown in menu). I need to my external ''upload'' php script use, when sending mail to admin, joomla variable ''$user->username'', and when send mail to admin, send ''who'' upload file->''username'' with other data.

P.S. Neither joomla upload plugin or module doesnt fits our needs!! Only work with thath php script.

Thanks!!!

Re: Script to display username or name..

Posted: Thu Dec 24, 2009 4:53 am
by jacomstephens
OK, so I've been able to get it to echo the username, name, id, etc. successfully, but I'm wondering if there is a way to use that username variable when calling a module. For example, I'm a photographer and I'd like to show clients their proofs using the YOOgallery module. When user bobandmarie logs in, it should show all the images in the /clients/proofs/bobandmarie folder. The syntax for calling the module is {yoogallery src=[/clients/proofs/username]} I want it to replace "username" with the username of whoever is currently logged in (in this example bobandmarie). How do I do that? I've tried:

$user =& JFactory::getUser();
$row->text = str_replace('username', $user->username, $row->text);

but that doesn't seem to do anything at all. Please help!

P.S. As a disclaimer, I only know enough PHP to get myself into trouble. ;)

Re: Script to display username or name..

Posted: Thu May 30, 2013 12:19 pm
by jeannie123
Which file do put the code into? could you please explain in details as I am new in this. thanks heaps

Re: Script to display username or name..

Posted: Wed Jun 19, 2013 10:41 am
by Snowyn
You must install an extension which can display php code. normal html module cannot make it...