0

I've been working on creating a feature which allows certain non-admin but higher-than-user roles within a Drupal 8.8 system to delete users from the system. In essence, only admin and 'moderator' accounts have access to the Drupal, and they need to all be able to 'cancel' a user account from a bulk action.

My problem is that despite setting all permissions correctly and according to the guides, the moderators are always given a choice to choose which cancellation method they wish to use on the account, and then need to confirm the deletion. This happens despite these accounts not having the permission to do so.

I simply want the system to, upon clicking on the action 'cancel this account,' to cancel and delete all the accounts without confirmation or anything else. Just click and go. I've tried implementing this using hooks, including hook_user_cancel_methods_alter as shown below by not giving administer rights and dropping that requirement, but nothing seems to work.

function clientname_user_cancel_methods_alter(&$methods) { 
  unset($methods['user_cancel_delete']['access']); 
}

Simply put: how can I skip the confirmation screen for a user cancellation/deletion in Drupal 8.8?

2
  • Welcome to Drupal Answers! The question should show which permissions are given to the roles, including the one for administering users. Users who have the administer users or the select account cancellation method permission always choose the deletion method, which means that if moderators have one of those permissions, they will always be able to choose which method to use for deleting an account.
    – apaderno
    Apr 13, 2021 at 18:17
  • As side note, not showing a confirmation form is a bad idea.
    – apaderno
    Apr 13, 2021 at 18:18

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.