Skip to content

Instantly share code, notes, and snippets.

@cPanelRyan
Last active September 11, 2020 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cPanelRyan/f3d8677e85e07e3655ac5fcc70e5b2ac to your computer and use it in GitHub Desktop.
Save cPanelRyan/f3d8677e85e07e3655ac5fcc70e5b2ac to your computer and use it in GitHub Desktop.
Hook Action Code: Perl Module Example
# Package this module.
package MyApp::WHM;
# Return errors if Perl experiences problems.
use strict;
use warnings;
# Properly decode JSON.
use JSON;
# Embed hook attributes alongside the action code.
sub describe {
my $my_add = {
'category' => 'Whostmgr',
'event' => 'Accounts::Create',
'stage' => 'post',
'hook' => 'MyApp::WHM::add',
'exectype' => 'module',
};
return [ $my_add ];
}
sub add {
# Get the data that the system passes to the hook.
my ( $context, $data ) = @_;
# Set success and failure messages.
my $result = 1; # This Boolean value is set to fail.
my $message = 'This is an error message.'; # This string is a reason for $result.
# Insert your actions here.
# Return the hook's result and message.
return $result, $message;
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment