removePage (function)

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

Purpose

Removes a page from permission_page_matches

Location

users/helpers/permissions.php

Parameters

# Parameter Data Type Required Description
1 $pages integer, array Yes The ID(s) of the page(s) to remove permissions from. Can be a single ID or an array of IDs.
2 $permissions integer, array Yes The ID(s) of the permission(s) to remove from the page(s). Can be a single ID or an array of IDs.

Returns

Data Type Description of Returned Data
int The function returns the number of affected rows (page permissions removed) as an integer.

Example

removePage($pages, $permissions)

Further Documentation:

This should only be done in the UserSpice dashboard.

$pageId = 123;
$permissionId = 456;

// Remove a single permission from a single page
$affectedRows = removePage($pageId, $permissionId);
echo "Removed $affectedRows permission(s) from page $pageId.";

// Remove multiple permissions from a single page
$permissionIds = [456, 789];
$affectedRows = removePage($pageId, $permissionIds);
echo "Removed $affectedRows permission(s) from page $pageId.";

// Remove a single permission from multiple pages
$pageIds = [123, 456];
$affectedRows = removePage($pageIds, $permissionId);
echo "Removed $affectedRows permission(s) from pages.";

// Remove multiple permissions from multiple pages
$affectedRows = removePage($pageIds, $permissionIds);
echo "Removed $affectedRows permission(s) from pages.";


In the examples above, the removePage function is called with different combinations of page and permission IDs. The function removes the page permission assignments for the specified pages and permissions in the permission_page_matches table. The returned affectedRows variable holds the count of removed page permissions. It is then used to display the number of permissions that were successfully removed.

Note that the function supports both single and multiple page/permission IDs, allowing you to remove permissions from individual pages or multiple pages at once.