fetchPagePermissions (function)

Last updated: Mon, Apr 17, 2023 9:24 am
Return to Knowledgebase

Purpose

Returns a list of permission levels that can access a page

Location

users/helpers/permissions.php

Parameters

# Parameter Data Type Required Description
1 $page_id integer Yes represents the unique identifier of the page for which permissions are to be fetched

Returns

Data Type Description of Returned Data
array of objects It returns an array of objects, with each object representing a permission associated with the page.

Example

fetchPagePermissions(1)

Further Documentation:

The fetchPagePermissions function takes an integer $page_id as its parameter, representing the unique identifier of the page for which permissions are to be fetched. The function queries the database to fetch a list of permission IDs associated with the specified page ID from the permission_page_matches table. It returns an array of objects, with each object representing a permission associated with the page. Each object has two fields: id, representing the unique identifier of the permission-page match, and permission_id, representing the unique identifier of the permission associated with the page.

Example usage:

// Fetch the permissions for page with ID 5
$page_id = 5;
$page_permissions = fetchPagePermissions($page_id);

// Print the permission IDs associated with the page
foreach ($page_permissions as $permission) {
echo $permission->permission_id . "
";
}