I would like to send an email to some users, when i put my Drupal-7 website in maintenance mode. Are there any hooks that allow me to do this? I could not figure it out for myself.

  • 3
    If you're enabling maintenance mode through the UI you can use hook_form_alter and add a submit handler which sends the email. If by drush/something else, you'd probably need to script it as part of that op – Clive May 17 '18 at 10:23

As @Clive said you can use hook_form_alter() or hook_form_FORM_ID_alter() and add extra submit handler to send email notifications.

function YOURMODULE_form_system_site_maintenance_mode_alter(&$form, &$form_state, $form_id) {
  $form['#submit'][] = 'email_system_settings_form_submit';

function email_system_settings_form_submit($form, &$form_state) {
  // Add your email code here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.