Last active
September 11, 2020 20:19
-
-
Save cPanelRyan/f3d8677e85e07e3655ac5fcc70e5b2ac to your computer and use it in GitHub Desktop.
Hook Action Code: Perl Module Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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