How to create hook that blocking API Calls
Hi,
I am really confused because I want to create hook for my plugin that would block actions in pre stage of hooks.
For example I want to create Account::Create action in case of wrong package
How Can I do that? I am running many hook examples, trying to return different response.
If that is even possible? If yes what should I return or what should I register?
[CODE=php]'category' => 'Whostmgr',
'event' => 'Accounts::Create',
'stage' => 'pre',
'hook' => '/usr/local/cpanel/whostmgr/docroot/cgi/myplugin/hooks.php --create',
'exectype' => 'script',
'weight' => 999,
],
-
Hey there! I'm not sure I completely understand what you are trying to do. Can you provide a different example or more details? 0 -
Hi, On every call Account::Create I want to check if my package is correct I want to do that in the hook, before create (pre). So I want to stop this call and return own result instead of standard api response. Shortly, I want to avoid account creating with that hook, Is that possible? if($package == 'wrong'){ // return message or result that would block api call return [0, 'Cannot create account, package is wrong'>; }0 -
Hi, Thanks! It helped, but I spent more than 4 hours to check what is wrong with my code. In your documentation there is info that is should be [CODE=php]die("BAILOUT: $message");
But it has to be [CODE=php]die("BAILOUT $message");0 -
I'm so sorry there was a typo in the guide! I've submitted a case to our team to get that code example updated so that will be adjusted soon. 0
Please sign in to leave a comment.
Comments
5 comments