You are here

function gdpr_consent_user_is_exempt in GDPR Consent 7

Check if user is exempt from consent.

Parameters

object $account: A user object.

Return value

bool True if the passed user is exempt.

3 calls to gdpr_consent_user_is_exempt()
gdpr_consent_form_user_profile_form_alter in ./gdpr_consent.module
Implements hook_form_FORM_ID_alter().
gdpr_consent_preprocess_page in ./gdpr_consent.module
Implements hook_preprocess_page().
gdpr_consent_user_login in ./gdpr_consent.module
Implements hook_user_login().

File

./gdpr_consent.module, line 1107
Module file for GDPR Consent.

Code

function gdpr_consent_user_is_exempt($account) {

  // User 1 is exempt from accepting Consents, no need to display consents.
  if (!is_object($account)) {
    return FALSE;
  }
  if ($account->uid === 1) {
    return TRUE;
  }
  $exempt_roles = variable_get('gdpr_consent_except_roles', array());
  $account_roles = $account->roles;
  $exempt_user_roles = array_intersect_key((array) $account_roles, $exempt_roles);
  if (count($exempt_user_roles)) {
    return TRUE;
  }
  return FALSE;
}