diff --git a/autologout.api.php b/autologout.api.php index c81f605..2e85fe3 100644 --- a/autologout.api.php +++ b/autologout.api.php @@ -58,3 +58,19 @@ function hook_autologout_refresh_only() { function hook_autologout_timeout_alter(&$timeout) { $timeout = 1800; } + +/** + * Allow the redirect URL and query to be modified prior to auto-logout. + * + * Use case: For example, if certain users such as Admins need to be + * redirected to a special admin-only URL. + */ +function hook_autologout_redirect_url_alter(&$redirect_url, &$redirect_query) { + global $user; + if ($user->name == 'jane.doe') { + $redirect_url = 'bye-jane'; + } + if ($user->name == 'mallory') { + $redirect_query['was_mallory'] = 1; + } +} diff --git a/autologout.module b/autologout.module index 9d6f4a9..a61747a 100644 --- a/autologout.module +++ b/autologout.module @@ -379,6 +379,9 @@ function autologout_init() { $use_alt_logout_method = variable_get('autologout_use_alt_logout_method', FALSE); drupal_add_library('system', 'ui.dialog'); + // Provide a hook to allow the redirect URL and query to be customised + drupal_alter('autologout_redirect_url', $redirect_url, $redirect_query); + // Get all settings JS will need for dialog. $msg = t(variable_get('autologout_message', 'Your session is about to expire. Do you want to reset it?')); $settings = array(