It takes a string of comma-separated page IDs as its parameter.
Returns
Data Type
Description of Returned Data
bool
Returns a boolean value indicating whether the deletion was successful or not.
Example
deletePages(2)
Further Documentation:
The deletePages() function in UserSpice is used to delete one or more pages from the database. It takes a string of comma-separated page IDs as its parameter, and returns a boolean value indicating whether the deletion was successful or not.
Here's the code for the deletePages() function:
function deletePages($pages)
{ $db = DB::getInstance();
if (!$query = $db->query("DELETE FROM pages WHERE id IN ({$pages})")) {
throw new Exception('There was a problem deleting pages.');
} else { cleanupPermissionPageMatches();
return true;
}
}
To use this function, you would pass a string of comma-separated page IDs to it. For example:
// Include UserSpice
require_once 'users/init.php';
// Delete pages with IDs 1, 2, and 3 $pagesToDelete = '1,2,3'; $result = deletePages($pagesToDelete);
if ($result) {
echo "Pages deleted successfully!";
} else {
echo "There was an error deleting the pages.";
}
?>
In this example, we first include the UserSpice framework by calling the init.php file. Then, we define a string variable $pagesToDelete that contains the IDs of the pages we want to delete, separated by commas. We then call the deletePages() function, passing the $pagesToDelete string as its parameter. If the deletion is successful, the function returns true and we display a success message. If there is an error, the function throws an exception and we display an error message.