$user


User Properties

$user->roles

Introduced in Version 2.0

Description

Get roles this user has. Returns PageArray.

Echo the current user's roles:

echo $user->roles; // Would return 37|38 for the default admin user after install
// 37 = guest, 38 = superuser
									

Iterate through the roles, echoing their names:

foreach ($user->roles as $role) {
    echo $role->name . "<br/>";
}
									

Which would output:

guest
superuser
									

Related

Post Comment