webCOMAND

User::check_authorized()

Check if a user is authorized with a specified Privilege.

Prototype

boolean check_authorized(string $ns = NULL, string $id = NULL, boolean $force = FALSE)

Parameters

  • ns - The privilege namespace to check for (default io_comand_auth).
  • id - The privilege identifier to check for (default CREATE).
  • force - Whether to force the cached authorizations to be reloaded.

Return

TRUE if this user is authorized for the specified Privilege, FALSE otherwise.

Example

$users = $repo->get("FROM User WHERE Email!=''");
foreach($users as $user) {
    if(!$user->check_authorized('com_webcomand', 'EDIT_CONTENT_TYPE')) {
        echo($user->get_full_name() . " can edit content types.\n" );
    }
}

Related

check_authorized_object()