Joomla: Accessing User Info - The User Object
To get user information for the current user:
$user = JFactory::getUser();
It will return the User Object.
Here, some of the most common User Object's Properties:
- id
($user->id)
- name
($user->name)
- username (
$user->username
)
- groups (
$user->groups
)
- email (
$user->email
).
You can check if the user is logged-in with the:
$user->guest;
You can check for the user's access privileges with the authorize method, e.g:
$user->authorise('core.admin', 'com_component')
User Profiles
For extra custom fields, this depends on what you are trying to achieve. There is a Joomla core plugin "User Profile" which contains many custom profile fields and which you can customize further.
Update: Accessing the User Profile Data
jimport( 'joomla.user.helper' );
$user = JFactory::getUser();
$userId = $user->id;
$userProfile = JUserHelper::getProfile( $userId );
echo "Main Address :" . $userProfile->profile['address1'];
At the other hand there are other 3rd party extensions like Community Builder, JomSocial, Easy Social that let you build a user community site, where you can have users with extended profile information.
If you don't need to build a community, there are other extensions that either override/extend the com_user core component or they work in conjunction with it and give you extra control over the user management.
But as said, it depends on what you want to do. For example if you just plan to build a forum, the forum extensions have extra profile fields.
Of course there are always more advanced solutions like building your own component or application.
Links