Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Just a heads up... This module won't work when the Protect Critical Users module is installed. The specific conflict is hook_form_alter.
/**
* Implementation of hook_form_alter().
*/
function protect_critical_users_form_alter(&$form, $form_state, $form_id) {
global $user;
// Remove delete button from user 1 edit form.
if ($form_id == 'user_profile_form' && isset($form['delete']) && isset($form['_account']['#value']->uid)) {
if ($form['_account']['#value']->uid == 1 || $form['_account']['#value']->uid == $user->uid) {
unset($form['delete']);
}
}
}
As you can see... Protect Critical Users unsets the delete button. Also might I suggest the thought of merging these modules? I'm not saying they do the same task. but the idea of users who can delete their own account while still protecting certain roles of super admin from doing so to their account.
Comment | File | Size | Author |
---|---|---|---|
#6 | protect_critical_users-user_delete-integration.patch | 1.32 KB | manuel.adan |
Comments
Comment #1
sanduhrsI will have a look at that.
Thanks.
Comment #2
mrfelton CreditAttribution: mrfelton commentedperhaps the critical_users module should not be unsetting the delete button, but instead setting
$form['delete']['#access'] = FALSE;
Comment #3
sanduhrsThat actually feels more like a issue for protect_critical_users module.
Comment #4
markus_petrux CreditAttribution: markus_petrux commentedThe life time of the Protect Critical Users (PCU) module is quite short, and it will end as soon as the core issue is fixed: #46149: Prevent account cancellation for uid 1. I do not plan to extend the module with anything else. It will simply die the day core is fixed.
So... I would suggest adding to User Delete whatever it may need to make PCU redundant.
As far as PCU is concerned, this is "won't fix" / "by design". Both modules are simply not compatible. If users need User Delete, then I would suggest asking UD for anything it may need to cover the whole picture. User Delete module will need it from D7 and on, because the core patch is about to get in pretty soon, it seems to me.
Comment #5
sanduhrsuser_delete module will not have a D7 release either as the functinality it provides is included in D7.
Closing.
Comment #6
manuel.adanThis may help both module to be used with no conflict. Note that patch is for the protect_critical_users module 6.x-1.1