Ad

Hide Tab "Groups" In User Backend Settings ("My Account") For User Role

- 1 answer

i need to hide "Groups" tab in user backend settings "My account" for one of user role.

I do not want the user to edit the groups.

Screenshot 1
Screenshot 2

Ad

Answer

Yes, you can easily do that

We allow only super user to see that groups tabs or in addition you can add more conditions there, but for now only super user can see that tab.

code

// specific to be users controller
\Backend\Controllers\Users::extendFormFields(function($form, $model, $context)        {
    if (!$model instanceof \Backend\Models\User) {
        return;
    }
    $backendUser = \BackendAuth::getUser();
    if(!$backendUser->is_superuser) {
        $form->removeField('groups');
    }
});

this will allow only super user to access that field

Ad
source: stackoverflow.com
Ad