Anoop P Alias

Well-Known Member
Mar 31, 2015
cPanel Access Level
Root Administrator


Active Member
May 21, 2018
cPanel Access Level
Root Administrator
Hi Anoop,

Although the script hook method is deprecated, they are still working and I've been using without an issue:

Guide to Standardized Hooks - Script Hooks - Developer Documentation - cPanel Documentation

The /scripts/restoreacct script's hooks trigger each time that the system restores an account.

pre hook script:


This script accepts the following arguments:

  • cpuser — The account's new (local) username.
  • olduser — The account's old (remote) username.
  • extractdir — The directory to which the system will extract the cpmove file.
post hook script:


This script accepts the following arguments:

  • user — The account's new (local) username.
  • olduser — The account's old (remote) username.
  • domain — The account's main domain.
  • user_homedir — The absolute path to the account's home directory.
Just place a script that bash can execute. Here's an example if you want to test it:

1. Make a file /scripts/postrestoreacct

2. Put in it:

ARRAY=([email protected])
for (( ARG=0 ; ARG < $ARRAYLENGTH ; ARG++ ))

echo "ARG$ARG=${ARRAY[$ARG]}"


3. chmod it to execute:
chmod +x /scripts/postrestoreacct

4. Restore a test account

If done correctly, you should see in the output of the restore log

[ 7511][RESTORE:1 ][A:demouser ]: Progress: 79% (2019-02-27 04:42:23 +0000)
[ 7511][RESTORE:1 ][A:demouser ]: PostRestoreActions
[ 7511][RESTORE:1 ][A:demouser ]: Updating Caches …
[ 7511][RESTORE:1 ][A:demouser ]: Enabling IPv6 for account …
[ 7511][RESTORE:1 ][A:demouser ]: Updating Nameserver IP Address Report
[ 7511][RESTORE:1 ][A:demouser ]: Syncing contact information
[ 7511][RESTORE:1 ][A:demouser ]: Running postrestore script
[ 7511][RESTORE:1 ][A:demouser ]: ARG0=demouser
[ 7511][RESTORE:1 ][A:demouser ]: ARG1=demouser
[ 7511][RESTORE:1 ][A:demouser ]:
[ 7511][RESTORE:1 ][A:demouser ]: ARG3=/home/demouser

[ 7511][RESTORE:1 ][A:demouser ]: PostRestoreActions

Knowing the argument positions to the script, you can do simple things to trigger on restore, like change a theme:
uapi --user="$1" Styles update type=default name=basic

Or set to the system version of PHP:
whmapi1 php_set_vhost_versions version=inherit vhost-0="$3"


Product Owner
Staff member
Nov 14, 2017
As indicated by @plesk4lyf the hooks system is really the way to go and if the event isn't hookable you can create a hookable event Guide to Standardized Hooks - Hookable Events in Custom Modules - Developer Documentation - cPanel Documentation though I wouldn't use the script hooks as they are deprecated. They are still usable at this time though.

The whostmgr functions would be what you want to look at Guide to Standardized Hooks - Whostmgr Functions - Developer Documentation - cPanel Documentation