Executing external scripts on User events/actions: on registration, on status change, on change and on delete.
support, ws.webtv, advanced, users, management, developers, scripts, webhooks, callbacks
Since WS.WebTV 2.0 it is possible to call external scripts on certain User events/actions.
How does it works?
If you specify the URLs of the scripts in the WebTV configuration file (config/Config.inc.php), the system will call those scripts when certain User events/actions occur.
This functionality can be complemented with the API extension. For example,
if you are integrating the WebTV with an external system, you can use these script calls (and the API) to synchronize both system.
This script is called when an User is registered/created (either from the front-end or back-end).
Data sent by the WebTV as POST variables:
• id (int): The User ID.
• login (string): The Login.
• alias (string): The Alias.
• email (string): The E-Mail.
• name (string): The Name (first name).
• surname (string): The Surname (last name).
• status (int): The Status. Possible values: 0=Inactive, 1=Active, 2=Pending Verification.
• ip (string): The IP - Since WS.WebTV 3.1 (R50).
• useragent (string): The "User Agent" - Since WS.WebTV 3.1 (R50).
• access_level (string): The "Access Level" - Since WS.WebTV v56pf4.
• id_privilege_set (string): The "Privilege Set" ID - Since WS.WebTV v56pf4.
• company (string): The "Company"/"Organization" - Since WS.WebTV v56pf4.
• reg_source (string): The "Registration Source" - This is the source/interface from which the User was registered - Since WS.WebTV v56pf4.
• original_post_data (string): The full POST data (escaped and JSON encoded) sent to the registration form - Since WS.WebTV v57.
Variable in configuration File
- Single Webhook case:
$USER_ON_REGISTRATION_SCRIPT_URL = "WEBHOOK_URL"; // Must be an absolute URL, starting with http:// or https://
- Multiple Webhooks case:
$USER_ON_REGISTRATION_SCRIPT_URL = array("WEBHOOK_URL1","WEBHOOK_URL2"); // Must be absolute URLs, starting with http:// or https://
This script is called when an User changes its status. For example, it will be called when an user verifies its account (status changes to 1) or if the User is manually activated/deactivated. Note that this script won't be called when the status of an User have changed after being modified/edited, in this case the "on change" script will be called.
Data sent by the WebTV as POST variables:
• id (int): The User ID.
• status (int): The User Status. Possible values: 0=Inactive, 1=Active, 2=Pending Verification.
Variable in configuration File:
$USER_ON_STATUS_CHANGE_SCRIPT_URL = ""; // Must be an absolute URL, starting with http:// or https://
This script is called when an User is modified/edited.
Data sent by the WebTV as POST variables:
• id (int): The User ID.
Variable in configuration File:
$USER_ON_CHANGE_SCRIPT_URL = ""; // Must be an absolute URL, starting with http:// or https://
This script is called when an User is deleted.
Data sent by the WebTV as POST variables:
• id (int): The User ID.
• login (string): The User login - Since WS.WebTV 3.0.2pf3.
Variable in configuration File:
$USER_ON_DELETE_SCRIPT_URL = ""; // Must be an absolute URL, starting with http:// or https://
(Since WS.WebTV v57pf) This script is called just before a User is deleted.
Data sent by the WebTV as POST variables:
• id (int): The User ID.
Variable in configuration File:
$USER_ON_BEFORE_DELETE_SCRIPT_URL = ""; // Must be an absolute URL, starting with http:// or https://
This script is called when an User logs in.
Data sent by the WebTV as POST variables:
• id (int): The User ID.
• ip (string): The User IP - Since WS.WebTV 3.1 (R50).
• useragent (string): The User "User Agent" - Since WS.WebTV 3.1 (R50).
Variable in configuration File:
$USER_ON_LOGIN_SCRIPT_URL = ""; // Must be an absolute URL, starting with http:// or https://
This script is called when an User logs out.
Data sent by the WebTV as POST variables:
• id (int): The User ID.
Variable in configuration File:
$USER_ON_LOGOUT_SCRIPT_URL = ""; // Must be an absolute URL, starting with http:// or https://