Every WHM shop ends up writing a postwwwacct hook eventually — to register a new account in their CRM, to push the domain into a DNS cluster, to add the customer to monitoring. The first version is usually a shell script in /scripts/postwwwacct, which works until the cPanel upgrade that wipes /scripts/ and the team learns the hard way that custom scripts there are not preserved. Standardized hooks are cPanel’s answer; the shape of the hook is the part that determines whether it survives the next upgrade.
What’s happening
cPanel ships two hook systems. The legacy form is a script at /scripts/postwwwacct invoked after every successful createacct. cPanel preserves that file across upgrades only in some upgrade paths; on a major version bump it can be silently overwritten. The Standardized Hooks system, introduced in cPanel 11.44, stores hooks in /var/cpanel/hooks/ with a manifest that survives upgrades, supports per-event filtering, supports hook chains, and gets called by name (Whostmgr::Accounts::Create) rather than by filename.
How to verify
List the hooks currently registered, both legacy and standardized:
ls /scripts/post*
ls -la /var/cpanel/hooks/
whmapi1 list_hooks
whmapi1 list_hooks category=Whostmgr
tail -f /usr/local/cpanel/logs/error_log | grep -i hook
whmapi1 list_hooks is the authoritative source. The output shows category, event, hook name, and the stage (pre or post). A hook missing from this list won’t fire even if the file exists.
The fix
A standardized post-account-creation hook in three steps:
- Drop the script in
/usr/local/cpanel/scripts/<your-org>-postwwwacct.pl(or any path; the registration step names it):
#!/usr/bin/perl
use strict;
use Cpanel::JSON ();
my $data = Cpanel::JSON::Load(do { local $/; <STDIN> });
my $user = $data->{user};
my $domain = $data->{domain};
my $owner = $data->{owner};
# Push to your CRM, DNS cluster, monitoring
system("/usr/local/bin/crm-sync --create --user=$user --owner=$owner");
exit 0;
- Register the hook:
whmapi1 add_hook category=Whostmgr event=Accounts::Create stage=post hook=/usr/local/cpanel/scripts/yourorg-postwwwacct.pl. The registration writes to/var/cpanel/hooks/registered_hooks.yaml, which cPanel preserves across upgrades. - Make the script idempotent. The hook fires once per create, but a hook chain can fire it with different arguments if other hooks share the event. Treat the script as if it could be called multiple times for the same user.
- Log everything to a dedicated file (
/var/log/yourorg-hooks.log) with the timestamp and the event payload. When the customer asks “did anything happen at account creation”, this is your answer.
For organizations running real onboarding workflows on top of cPanel, Stack Harbor’s cPanel server management practice ships a hook library that covers the common cases — CRM sync, DNS cluster push, monitoring add — as a starting point any shop can extend.