Does the user have the given permission?
Example
if($user->hasPermission('page-publish')) {
// user has the page-publish permission in one of their roles
}
if($user->hasPermission('page-publish', $page)) {
// user has page-publish permission for $page
}
Usage
// basic usage
$bool = $user->hasPermission($name);
// usage with all arguments
$bool = $user->hasPermission($name, $context = null);
Arguments
Name | Type(s) | Description |
---|---|---|
name | string, Permission | Permission name, object or id. |
context (optional) | Page, Template, bool, string | Page or Template...
|
Return value
bool
array
API reference based on ProcessWire core version 3.0.236