checkPermission (function)

Last updated: Wed, Jan 4, 2023 5:55 am
Return to Knowledgebase

Purpose

Checks if a user has a permission level

Location

users/helpers/permissions.php

Version Information

First Introduced v1.0.0
Deprecated v5.2.6

See Also:

checkMenu (function)
hasPerm (function)

Parameters

# Parameter Data Type Required Description
1 $permission int Yes The id of the permission level you want to check.

Returns

Data Type Description of Returned Data
bool Returns true or false depending on if a user has the given permission level. Always returns true for user id #1.

Example

$permission = checkPermission(2);

Further Documentation:

This is an old UserCake function that checks if the logged in user has a certain permission level. This automatically returns true if the user's id is 1

if(checkPermission(2)){
echo "The user has permission level 2";
}

This function was deprecated after version 5.2.6.