HOW TO GET THE NAME, EMAIL OR OTHER USER INFO IN J

HOW-TO-GET-THE-NAME-EMAIL-OR-OTHER-USER-INFO-IN-J

24 May 2017

HOW TO GET THE NAME, EMAIL OR OTHER USER INFO IN J

In Joomla, you can easily request information about the current user with the following function of JFactory.

 


$user =& JFactory::getUser();

 


If you want to get information about a specific user you can call the function with a specific user id or username:

 


$user =& JFactory::getUser(463);

$user =& JFactory::getUser(george);

 


You can also get most of the information about the user through Member Variables of the user object like the user's name or email:

 


$user_name = $user->name;

$user_email = $user->email;

 


Here is a list with the Member Variables of the user object:

id - The unique, numerical user id.

name - The name of the user.

username - The login/screen name of the user.

email - The email address of the user.

password - The encrypted version of the user's password.

password_clear - Set to the user's password only when it is being changed. Otherwise, remains blank.

usertype - The role of the user within Joomla! (Super Administrator, Editor, etc...).

block - Set to '1' when the user is set to 'blocked' in Joomla!.

registerDate - Set to the date when the user was first registered.

lastvisitDate - Set to the date the user last visited the site.

sendEmail

activation

groups

guest - If the user is not logged in, this variable will be set to '1'. The other variables will be unset or default values.

If you want to know if the user is logged in, you can use the guest Member Variable:

 


$user =& JFactory::getUser();

if ($user->guest) { echo 'You are not logged in'; } else { echo 'You are logged in'; }

 

 

 

Source :- http://www.minitek.gr/blog/how-to-get-the-name-email-or-other-user-info-in-joomla

Want To Work With Us Then Feel Free To Contact Us