Skip to content

Instantly share code, notes, and snippets.

@ivangrozni
Last active November 17, 2023 12:09
Show Gist options
  • Save ivangrozni/7faa2701868285fd1660b7ec3307d51d to your computer and use it in GitHub Desktop.
Save ivangrozni/7faa2701868285fd1660b7ec3307d51d to your computer and use it in GitHub Desktop.
LDP-2151--password-policy
From e0c47758a3c589a4ad279c8480d29c0e4e0daed6 Mon Sep 17 00:00:00 2001
From: Brian Tofte-Schumacher <btofte-schumacher@forumone.com>
Date: Wed, 17 May 2023 12:27:35 -0400
Subject: [PATCH] Hide fields instead of preventing access, so the values
update
---
password_policy.module | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/password_policy.module b/password_policy.module
index 87f1502..19c86db 100644
--- a/password_policy.module
+++ b/password_policy.module
@@ -67,9 +67,9 @@ function password_policy_form_user_form_alter(&$form, FormStateInterface $form_s
// Hide password reset field if no access.
$account = \Drupal::currentUser();
if (!$account->hasPermission('manage password reset')) {
- $form['field_last_password_reset']['#access'] = FALSE;
- $form['field_password_expiration']['#access'] = FALSE;
- $form['field_pending_expire_sent']['#access'] = FALSE;
+ $form['field_last_password_reset']['#type'] = 'hidden';
+ $form['field_password_expiration']['#type'] = 'hidden';
+ $form['field_pending_expire_sent']['#type'] = 'hidden';
}
// Load form if relevant.
--
GitLab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment