User Helper
A collection of helper functions included with the Users module.
Functions
is_logged_in()
Checks if the user is logged in. Returns bool.
group_has_role($module, $role)
Checks if the current users group has a specific role. Returns bool.
Name | Default | Required | Description |
---|---|---|---|
module | Yes | Module slug | |
role | Yes | The role to test against |
// usage
group_has_role('pages', 'put_live');
role_or_die($module, $role, $redirect_to = 'admin', $message = '')
Tests if the current user has a specific role or redirects with a flashdata message.
Name | Default | Required | Description |
---|---|---|---|
module | Yes | Module slug | |
role | Yes | The role to test against | |
redirect_to | admin | No | The URL to redirect to if no access |
message | lang('cp_access_denied') | No | The flashdata message to display if no access |
// usage
role_or_die('pages', 'edit', 'admin/dashboard', 'Sorry, you can\'t edit pages.')
user_displayname($user, $linked = true)
Return a users display name based on settings.
Note: If no
display_name
is set, this function will return the username
instead.Name | Default | Required | Description |
---|---|---|---|
user | Yes | The ID of the user | |
linked | true | No | Include a link to the users profile? |