function legal_user_is_exempt in Legal 8
Same name and namespace in other branches
- 7 legal.module \legal_user_is_exempt()
- 2.0.x legal.module \legal_user_is_exempt()
Check if user is exempt from Terms & Conditions.
Parameters
object $account: User account object.
Return value
bool TRUE if user is exempt, FALSE otherwise.
2 calls to legal_user_is_exempt()
- legal_form_user_form_alter in ./
legal.module - Implements hook_form_FORM_ID_alter().
- legal_user_login in ./
legal.module - Implements hook_user_login().
File
- ./
legal.module, line 851 - Module file for Legal.
Code
function legal_user_is_exempt($account) {
// User 1 is exempt from accepting T&Cs, no need to display T&Cs.
if ($account
->id() == 1) {
return TRUE;
}
$settings = \Drupal::config('legal.settings');
$exempt_roles = $settings
->get('except_roles');
$account_roles = $account
->getRoles(TRUE);
if (count(array_intersect($exempt_roles, $account_roles))) {
return TRUE;
}
return FALSE;
}