FAQ - Plugin uninstall.php

FAQ - Plugin uninstall.php


Let's explain how to build the uninstall.php for a plugin.


// Include the config file...
if (!file_exists('../../config.php')) die('[uninstall.php] config.php not found');
require_once '../../config.php';

// If not logged in...
if (!JAK_USERID) die('You cannot access this file directly.');

// If not an admin...
if (!$jakuser->jakAdminaccess($jakuser->getVar("usergroupid"))) die('You cannot access this file directly.');

// Set successfully to zero
$succesfully = 0;

This few lines needs to be in every uninstall.php file for security purpose! The first line will include the config.php file from the root directory with all the necessary information like database connection, settings and user-group permission.

The next two functions will check that the user calls the file has permission to do so!

Please open any uninstall.php file to check how I proceed with the rest, I commented it thru so it should be easy to understand!