Disable Bulk user actions

Disable Bulk user actions

by Do Jacobson -
Number of replies: 4
Hi all,

I'm busy customizing Moodle for my company, and am now busy creating custom roles, however I haven't come across a role in which the user is allowed to create and view users, but unable to do bulk user actions.

Is there an easy way to disable the bulk user actions in the site administration panel?

Thanks!
Average of ratings: -
In reply to Do Jacobson

Re: Disable Bulk user actions

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Do - There is no particular capability for bulk_users. Instead each operation (such as creating, deleting or updating a user) has its own capability. In terms of viewing the link to bulk user actions, all of them are shown but not permitted if the user has any of them. Take a look at /admin/settings/users.php and at the beginning you will see that it says if a user is able to configure the site or has the capability to either update, create, or delete users then show the menu. So it is possible that a user will see the option to delete users in bulk; however, they will not be able to do so if they try. If you wanted to limit it to just site admins you could add an additional capability check around line 72. Alternatively, although I've not tested this, but it looks like you could remove the array of capabilities in the admin_externalpage function and it would use the site config capability by default. I hope that helps. Let me know if you have any questions. Peace - Anthony
In reply to Anthony Borrow

Re: Disable Bulk user actions

by Do Jacobson -
Hey Anthony,

Thanks for your reply, I tried the admin_externalpage approach and it works great. Instead of removing it from the array I made a bypass for users which have the primary admin role assigned. As I am the only person in the database with the permission to set roles it's an easy way to exclude all others from that particular page.

Cheers,
Do
In reply to Do Jacobson

Re: Disable Bulk user actions

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Do - Sounds like a good approach. Happy Moodling! Peace - Anthony