I'm testing an external email collection service that appears periodically at certain time intervals on a site.
When a user completes the form, the application can pass the email address as a variable in a POST request to a specific url.
What hook should I use to catch and process the email address at this one specific url?
I thought of using hook_init() something like the following, but I'm not sure if this is a good way to do something like this?
/**
* Implements hook_init()
* Check for variable sent via POST and process if found
*/
function mymodule_init() {
if (drupal_get_path_alias() == "myurl") {
if (isset($_POST['email_variable'])) {
<custom processing>;
}
}
}
Notes:
- The url is a normal node page that already exists on the site.
- The form is externally hosted, so a form alter is not an option.