Script to display username or name..

For Joomla! 1.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Locked
User avatar
flazai
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Fri Dec 19, 2008 8:59 am
Contact:

Script to display username or name..

Post by flazai » Fri Dec 19, 2008 9:38 am

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..

prateekshaweb
Joomla! Explorer
Joomla! Explorer
Posts: 331
Joined: Mon Aug 04, 2008 8:00 am
Location: India
Contact:

Re: Script to display username or name..

Post by prateekshaweb » Sun Jan 11, 2009 7:54 am

$user =& JFactory:;getUser();

echo $user->username;

you can create a module....and insert it in your page
Sumeet Shroff
PSD to Joomla, Joomla Custom Template Design and Virtuemart Shopping Cart
http://www.prateeksha.com http://www.joomlawebsitedesigners.com

User avatar
flazai
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Fri Dec 19, 2008 8:59 am
Contact:

Re: Script to display username or name..

Post by flazai » Mon Jan 12, 2009 2:04 am

Dear Prateeksha,

Thanks for your help..
:)

zacharyrs
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 135
Joined: Fri May 02, 2008 11:57 pm

Re: Script to display username or name..

Post by zacharyrs » Tue Mar 03, 2009 5:05 am

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?

prateekshaweb
Joomla! Explorer
Joomla! Explorer
Posts: 331
Joined: Mon Aug 04, 2008 8:00 am
Location: India
Contact:

Re: Script to display username or name..

Post by prateekshaweb » Tue Mar 03, 2009 5:37 am

yes...my mistake... there was a ; (semicolon) instead of a :colon near getUser();

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

echo $user->username;
?>
Sumeet Shroff
PSD to Joomla, Joomla Custom Template Design and Virtuemart Shopping Cart
http://www.prateeksha.com http://www.joomlawebsitedesigners.com

zacharyrs
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 135
Joined: Fri May 02, 2008 11:57 pm

Re: Script to display username or name..

Post by zacharyrs » Tue Mar 03, 2009 5:49 am

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?

User avatar
ivan_mef
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Wed Sep 23, 2009 3:00 am
Location: Split, Croatia
Contact:

Re: Script to display username or name..

Post by ivan_mef » Wed Sep 23, 2009 1:01 pm

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!!!

jacomstephens
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Sun Dec 20, 2009 12:27 am

Re: Script to display username or name..

Post by jacomstephens » Thu Dec 24, 2009 4:53 am

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. ;)

jeannie123
Joomla! Apprentice
Joomla! Apprentice
Posts: 31
Joined: Thu May 16, 2013 7:42 am

Re: Script to display username or name..

Post by jeannie123 » Thu May 30, 2013 12:19 pm

Which file do put the code into? could you please explain in details as I am new in this. thanks heaps

Snowyn
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Wed Jun 19, 2013 10:39 am

Re: Script to display username or name..

Post by Snowyn » Wed Jun 19, 2013 10:41 am

You must install an extension which can display php code. normal html module cannot make it...


Locked

Return to “Joomla! 1.5 Coding”