Score:0

Restrict permissions for user to only allow certain user managing actions

de flag

I would like to restrict permissions for a user to only allow certain user managing actions like for example blocking other users and / or deleting them.

This is meant for a user role like a moderator for forums.

Is there any module that can do that? I mostly found modules that restrict access to content but not much for restricting actions concerning user actions.

If not how could I implement this in a hook? It should apply for the /admin/people view and of course also the /user/username/edit forms.

I am searching for something working for Drupal 8 / 9.

Thanks a lot for any hints

cn flag
Drupal includes an **Administer users** permission on the permissions page. However, any user with this permission can do all editing tasks (blocking, deleting, changing passwords) for any user on the site. If that's ok, just create a role, add the permission to the role, and then assign the role to the users you want to be your moderators. If you need something else, you will need to describe what you are trying to do in more detail.
de flag
Thank you. I knew that. I want to only allow some of the tasks that **Administer users** would allow. Is there a way to at least hide the others like for example only allowing deleting and blocking users?
cn flag
You can use the Rules module to create an action "Delete a user" or "Block a user" and limit that action to the specified role. Then you can use the VBO/Views Bulk Operations module to add that action to a custom admin view to make it accessible to the users.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.