Jump to content

Administrator permissions for module


sherwin_flight

Recommended Posts

Hello,

 

I have built a module for WHMCS, and after much work I have it working exactly as I want, with ONE minor exception.

 

Under Setup > Addon Modules you can configure the permissions for each of the modules.

 

Based on these permissions you can limit which administrator groups can access the module page. WHMCS takes care of this just fine.

 

However, I also need this same functionality in my hooks.php file for my module. Basically, if an administrator does NOT have permissions to access the module page, I don't want the hooks to run either.

 

How can I go about figuring out if the currently logged-in administrator has module permissions from my hooks file?

Link to comment
Share on other sites

you need to query database table "tbladdonmodules" to get the allowed admin groups that you configured in Setup -> Addon Modules page

select `value` from tbladdonmodules where `setting` = 'access' and `module` = '{Your-Module-Name-Here}'; 

 

this will give you list of allowed admin role IDs separated by comma, you will have to parse it and compare logged in admin role ID with it:

select `roleid` from tbladmins where `id` = '$_SESSION['adminid']'

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