Add exemption hook to allow other modules to exempt users from Accepting T&C

Created on 10 July 2024, 5 months ago

Problem/Motivation

The module has an exception for the Masquerade module. It would me nice if this module allowed other module developers to exempt a user from accepting the T&C. This is a follow up from πŸ› Add exemption api to allow a Masquerade module exemption Needs review .

Consider the following workflow. A site allows users to create users and assigns them a role on registration. However, in order to post comments the user must first accept the T&C of the site before they are allowed to create comments. All the developer would have to do is implement the hook.

/**
 * Tells the Legal Module to exempt a user from accepting the Legal forms.
 *
 * @param $is_exempt
 *  Set to TRUE if the user is exempt from the legal module requirements.
 */
function hook_is_legal_exempt(&$is_exempt) {
// Masquerading users are exempt from the legal module requirement.
  if (\Drupal::service('module_handler')->moduleExists('masquerade')) {
    if (\Drupal::service('masquerade')->isMasquerading()) {
      return TRUE;
    }
  }
}

Proposed resolution

I already created a MR that allows for this. See https://git.drupalcode.org/project/legal/-/merge_requests/14

Remaining tasks

Maintainer approval and commit.

User interface changes

none

API changes

Adds a hook.

/**
 * Tells the Legal Module to exempt a user from accepting the Legal forms.
 *
 * @param $is_exempt
 *  Set to TRUE if the user is exempt from the legal module requirements.
 */
function hook_is_legal_exempt(&$is_exempt) {
// Masquerading users are exempt from the legal module requirement.
  if (\Drupal::service('module_handler')->moduleExists('masquerade')) {
    if (\Drupal::service('masquerade')->isMasquerading()) {
      return TRUE;
    }
  }
}

Data model changes

none

✨ Feature request
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States frob US

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024