Disable Backend User Groups
15
Disabling user group UI items is a great way of decluttering your backend for projects that don't use the features.
Firstly, this code is required in your plugin's Plugin.php:
use Backend\Controllers\Users as BackendUserController;
// ...
public function boot()
{
BackendUserController::extend(function ($controller) {
$controller->listConfig = $controller->makeConfig($controller->listConfig);
$controller->listConfig->toolbar = array_merge($controller->listConfig->toolbar, ['buttons' => '$/acme/blog/partials/toolbar.users.htm']);
});
BackendUserController::extendListColumns(function ($list, $model) {
$list->removeColumn('groups');
});
BackendUserController::extendFormFields(function($form, $model, $context) {
$form->removeField('groups');
});
}
Make sure to replace acme/blog
with the name of your plugin.
Finally, create the file partials/toolbar.users.htm
in your plugin's root directory, with the following code:
<div data-control="toolbar">
<a href="<?= Backend::url('backend/users/create') ?>" class="btn btn-primary oc-icon-plus">
<?= e(trans('backend::lang.user.new')) ?>
</a>
<?php if ($this->user->isSuperUser()): ?>
<a href="<?= Backend::url('backend/userroles') ?>" class="btn btn-default oc-icon-address-card">
<?= e(trans('backend::lang.user.role.list_title')) ?>
</a>
<?php endif ?>
</div>
There are no comments yet
Be the first one to comment