Jump to content

How to add column in user page list in admin


adrianmak
 Share

Recommended Posts

The user page list in admin only show three fields, name, email and roles

I added other fields in user page for other user information like date of birth

I want to show additional field column in user page list in admin

post-2272-0-87604500-1463797091_thumb.pn

Admin can add additional column in the column tab, but it will not keep permanent when log-out

Link to comment
Share on other sites

  • 2 years later...
1 hour ago, loukote said:

Would you know whether there is a way to set the default order to other than by username?

You can set the default sort via a hook in /site/ready.php:

$wire->addHookBefore('ProcessPageLister::execute', function(HookEvent $event) {
	/* @var ProcessPageLister $lister */
	$lister = $event->object;
	// Only for Users lister
	if($lister->parent->id !== 29) return;
	// Set the sort to whatever
	$lister->defaultSort = 'email';
});

Note that the user can change the sort within the lister, and this will persist for the current session. So to get back to the default sort you are setting in the hook the user would need to reset the lister:

2019-01-26_115331.png.259892244202c0c2c815dc289892afc0.png

Or if you want the default sort to apply every time the Users lister is visited (but still allow the user to change the sort while they are using the lister) then you could do this:

$wire->addHookBefore('ProcessPageLister::execute', function(HookEvent $event) {
	/* @var ProcessPageLister $lister */
	$lister = $event->object;
	// Only for Users lister
	if($lister->parent->id !== 29) return;
	// Reset the sort when the lister is first loaded
	if(!$event->config->ajax) $lister->sessionSet('sort', '');
	// Set the sort to whatever
	$lister->defaultSort = 'email';
});

 

  • Like 3
  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...