Jump to content

How to disable the TERMINATE module command operation for some or all admin users?


itomic

Recommended Posts

Hi All,

 

We've had a couple of occasions where hosting accounts have been accidentally terminated using the terminate module command in WHMCS, and I want to stop this.

 

I can see that it's possible to enable/disable *all* modules commands ("Perform Module Command Operations") per admin role, but I want to see if I can disable *only* the terminate command.

 

WHMCS documentation doesn't appear to be coughing up the answer.

 

Thanks for your help,

 

Ross

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

sentq has a good idea here. You can do this using the PreModuleTerminate hook. The "Terminate" button will still show, but you can have it abort, if the admin is not allowed to run it.

 

Create a new hook file under your includes/hooks folder called something like "termperm.php". Within that file, use the following code:

<?php

if (!defined("WHMCS"))
   die("This file cannot be accessed directly");

function terminate_permission($params) {

 // Admin IDs who are allowed to use the Terminate function
 $termallow = array('1','2','3');

 if ($_SESSION['adminid'] && !in_array($_SESSION['adminid'], $termallow)) {
   $return = array("abortcmd"=>true);
   return $return;
 }

}

add_hook("PreModuleTerminate",1,"terminate_permission");

?>

 

Be sure to edit the "$termallow" array, with a list of admin ids that are allowed to use the Terminate function.

 

I tested this on my dev server, and it worked well for me.

Edited by SeanP
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated