First of all, before executing below code you should use Joomla’s Sourcerer plugin to execute PHP code.
If you want to get information about a specific user you can call the function with a specific user id or username:
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.
– 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:
'You are not logged in'
'You are logged in'