permissionIdExists (function)

Last updated: Fri, May 26, 2023 9:06 am
Return to Knowledgebase

Purpose

Tells whether a permission id exists in UserSpice

Location

users/helpers/permissions.php

Parameters

# Parameter Data Type Required Description
1 $id integer Yes The ID of the permission to check.
2 No

Returns

Data Type Description of Returned Data
bool The function returns a boolean value (true or false) indicating whether the permission ID exists in the permissions table of the database.

Example

permissionIdExists(2)

Further Documentation:

This is generally an internal UserSpice function and is not usually used by developers.
$permissionId = 123;

if (function_exists('permissionIdExists') && permissionIdExists($permissionId)) {
echo "Permission ID $permissionId exists.";
} else {
echo "Permission ID $permissionId does not exist.";
}


In the example above, the function_exists check is performed to ensure that the permissionIdExists function is defined. Then, the permissionIdExists function is called with the $permissionId variable as the argument. Based on the return value, it prints a corresponding message indicating whether the permission ID exists or not.