Support

Home Forums Event Espresso Premium Sorting by custom column in Event's registration table

Sorting by custom column in Event's registration table

Posted: April 6, 2018 at 11:54 am


bhesketh

April 6, 2018 at 11:54 am

Hi

I’ve added custom column to Event Registrations admin table and now need to enable sorting of registrations by that column.

Is there a sorting filter for that?

Thank you for helping!


Tony

  • Support Staff

April 12, 2018 at 4:19 am

Hi there,

It turns out there is a filter for this:

$_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen);

To add sorting to a custom column named ‘custom_column’, you would do something like this:

function tw_ee_sortable_columns( $sortable_columns, $screen ) {
	if ( $screen == 'espresso_registrations_default' ) {
		$sortable_columns['custom_column'] = array('custom_column' => TRUE);
	}
	return $sortable_columns;
}
add_filter('FHEE_manage_event-espresso_page_espresso_registrations_sortable_columns', 'tw_ee_sortable_columns', 10, 2);


bhesketh

April 12, 2018 at 10:18 am

Thank you. The code kind of works, but the sorting doesn’t work right.

Is there still anything missing?


bhesketh

April 12, 2018 at 1:37 pm

I’m able to click on column heading, the URL shows proper information ASC and DESC by the proper field, but the sorting doesn’t work right.

function tw_ee_sortable_columns( $sortable_columns, $screen ) {
if ( $screen == ‘espresso_registrations_default’ ) {
$sortable_columns[‘myCustomColumnName’] = array(‘myCustomColumnName’ => TRUE);
}
return $sortable_columns;
}
add_filter(‘FHEE_manage_event-espresso_page_espresso_registrations_sortable_columns’, ‘tw_ee_sortable_columns’, 10, 2);


bhesketh

April 12, 2018 at 1:38 pm

here is the URL – /wp-admin/admin.php?page=espresso_registrations&orderby=myCustomColumnName&order=asc


Tony

  • Support Staff

April 12, 2018 at 2:10 pm

What values are in your custom column?

You must be logged in to reply to this support post. Sign In or Register for an Account

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3

Documentation for Event Espresso 4

Status: publish

Updated by  Tony 2 weeks ago ago

Topic Tags

Notifications

This topic is: not resolved
Do NOT follow this link or you will be banned from the site!