function gdpr_consent_preprocess_page in GDPR Consent 7
Implements hook_preprocess_page().
File
- ./
gdpr_consent.module, line 32 - Module file for GDPR Consent.
Code
function gdpr_consent_preprocess_page() {
global $user;
// Ensure user register has drupal collapse even if submit fails.
$args = arg();
$block_admin = variable_get('gdpr_consent_block_admin', 0);
// Do not block admin pages if set so.
if (!$block_admin && !empty($args[0]) && $args[0] == 'admin') {
return;
}
// Add collapse library at register.
if (!empty($args[1]) && $args[0] == 'user' && $args[1] == 'register') {
drupal_add_library('system', 'drupal.collapse');
}
// If role is exempt, ignore possible redirects.
if (gdpr_consent_user_is_exempt($user)) {
return;
}
// If Consent is forced, prevent user from using site before valid consent.
$forced_consent = variable_get('gdpr_consent_disallow_without');
if ($forced_consent || !empty($_SESSION['no_consent_on_login']) && $_SESSION['no_consent_on_login'] == TRUE) {
$destination = '';
gdpr_consent_redirect_to_consent($destination);
}
}