Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Event::on(
- Cp::class,
- Cp::EVENT_REGISTER_CP_NAV_ITEMS,
- function(RegisterCpNavItemsEvent $event){
- // the 4th element is the "User", you can change the URL to your
- // custom controller instead of the default template
- // I suggest you to loop all `navItems` and find
- // the correct user instead of assuming it's the 4th
- // Craft::dd($event->navItems);
- $event->navItems[4]['url'] = ['template' => 'path/to/template/user'],
- });
- {% if CraftEdition != CraftPro %}
- {% exit 404 %}
- {% endif %}
- {% requirePermission 'editUsers' %}
- {% extends "_layouts/elementindex" %}
- {% set title = "Users"|t('app') %}
- // changes start
- // replace the elementType with your custom element type
- {% set elementType = 'prefix\namespace\elements\User' %}
- // changes end
- {% block actionButton %}
- {% if currentUser.can('registerUsers') %}
- <a class="btn submit add icon" href="{{ url('users/new') }}">{{ "New user"|t('app') }}</a>
- {% endif %}
- {% endblock %}
- class User extends craftelementsUser{ //<-- extend the default User element
- /**
- * @inheritdoc
- */
- protected static function defineSources(string $context = null): array
- {
- $sources = [
- [
- 'key' => '*',
- 'label' => Craft::t('app', 'All users'),
- 'criteria' => ['status' => null],
- 'hasThumbs' => true
- ]
- ];
- // Overwrite the sources / usergroups...
- // usually Craft will search for usergroups at this place..
- // just leave it empty, so you'll only see the "default" group
- return $sources;
- }
- }
Add Comment
Please, Sign In to add comment