How can I get an username in user view

For Joomla! 3.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Locked
adrian24
Joomla! Apprentice
Joomla! Apprentice
Posts: 24
Joined: Thu Nov 06, 2014 9:55 am

How can I get an username in user view

Post by adrian24 » Thu Dec 14, 2017 9:21 am

Hi,

Sorry for my English,

I have to get an user name from field "User" in User view. I need to create directories for each user in joomla folders on ftp and I need for this an username of the user.
ex2.jpg
How can I do this?

Regards Adrian
You do not have the required permissions to view the files attached to this post.

User avatar
lefteriskavadas
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 101
Joined: Fri Feb 05, 2016 6:10 pm
Location: Athens, Greece
Contact:

Re: How can I get an username in user view

Post by lefteriskavadas » Thu Dec 14, 2017 10:40 am

Hi,

It depends on the context. In general to get the current user you can use the following code:

Code: Select all

$user = JFactory::getUser();
Or if you want to get a specific user by ID you can use:

Code: Select all

$user = JUser::getInstance($id);
Finally, after you get the user, you can use the following code to access the username:

Code: Select all

$username = $user->username;
Joomla Extensions https://www.firecoders.com/


Locked

Return to “Joomla! 3.x Coding”