Support

Home Forums Event Espresso Premium Sort dashboard by event date

Sort dashboard by event date

Posted: October 31, 2024 at 12:17 pm

Viewing 22 reply threads


weblinxinc

October 31, 2024 at 12:17 pm

Is it possible to sort the events dashboard by date on load?


weblinxinc

October 31, 2024 at 12:18 pm

To clarify, we know you can click the headings in the table, but we’d like the initial sort order to be by the events date.


weblinxinc

October 31, 2024 at 12:20 pm

A couple of additional questions from my client if you don’t mind, or I can open separate threads…

> If someone registers for an event and an account is created for them, will subsequent registrations with the same email address appear in that users account?

> While doing a test registration, I couldn’t find a way to go back to the Registration/Attendee Information screen after proceeding to payment options. I imagine someone might need to go back to correct a name misspelling or email address, etc. Is this possible?


Tony

  • Support Staff

November 1, 2024 at 7:40 am

Hi there,

Is it possible to sort the events dashboard by date on load?

Yes, its possible using a snippet like this:

https://gist.github.com/joshfeck/3ad962e282219f922021ebf55d6d79e2

That just sets the filters using the Query string for the menu item and as it stands orders ASC and only upcoming events.

From the above you’ll likely need something like:

'admin.php?page=espresso_events&orderby=Datetime.DTT_EVT_start&order=desc';

> If someone registers for an event and an account is created for them, will subsequent registrations with the same email address appear in that users account?

Only if using the same First Name, Last Name and Email, but yes.

Note for this to work they need the WP user integration add-on active.

> While doing a test registration, I couldn’t find a way to go back to the Registration/Attendee Information screen after proceeding to payment options. I imagine someone might need to go back to correct a name misspelling or email address, etc. Is this possible?

Not from Payment Options to Attendee info no, they would need to restart the registration currently.

However, the thank you page does have the option to edit the registrant date and a link can be included in the emails if needed.


weblinxinc

November 1, 2024 at 1:42 pm

Great, thanks for the info! One more related question, is there a filter on the “Overview” tab link as well? https://imgur.com/a/ardJdiM


Tony

  • Support Staff

November 1, 2024 at 3:25 pm

Not that I can see but I’ve asked one of our devs to double check.


weblinxinc

November 15, 2024 at 1:42 pm

Have you heard back about this question? We’d also like to modify the “Event Espresso” link in the admin toolbar… our client is very pick about ordering.

Additionally, is there any way to adjust the query used on the overview page? We’d like to exclude a specific category unless it’s explicitly selected.


weblinxinc

November 15, 2024 at 1:59 pm

Somewhat related…

1. The filters on the “Overview” page don’t seem to be working correctly; for “Select a Month/Year” we only see “September 2025,” but there are many events in other months.
2. Is there any way to sort by a date range? If you can point me to the hooks, I can implement this myself.
3. Is there any way to allow searching in the dashboard to include searching by venue?


Tony

  • Support Staff

November 19, 2024 at 5:39 am

Have you heard back about this question? We’d also like to modify the “Event Espresso” link in the admin toolbar… our client is very pick about ordering.

Currently you can’t filter those URLs, not the overview or admin toolbar menu (we’ll technically you can with the admin bar but you would need to use the admin_url WordPress hook and it’s applied everywhere.

Additionally, is there any way to adjust the query used on the overview page? We’d like to exclude a specific category unless it’s explicitly selected.

Yes, and actually you would be better using that to filter the default covering and leave the URL’s as they are.

The hook to filter the query is FHEE__Events_Admin_Page__get_events__query_params

To change the default ordering you can do something like this:

https://gist.github.com/Pebblo/833a66cc6a191b7df99a72b53727a01f

(Remove the snippet I get you above HERE)

If you change the default ordering that will apply to all locations when no additional filtering is set.

1. The filters on the “Overview” page don’t seem to be working correctly; for “Select a Month/Year” we only see “September 2025,” but there are many events in other months.

Hmm, strange.

Have those events been published?

Is this with no other filters applied?

2. Is there any way to sort by a date range? If you can point me to the hooks, I can implement this myself.

A filter to add an additional filter for a range to apply?

If so there’s a dynamic filter for this:

$filters   = apply_filters(
    "FHEE__{$classname}__filters",
    $this->_get_table_filters(),
    $this,
    $this->_screen
);

For the EE event list table the hook name would be FHEE__Extend_Events_Admin_List_Table__filters.

You can apply the values to the query using the same filter from above FHEE__Events_Admin_Page__get_events__query_params.

3. Is there any way to allow searching in the dashboard to include searching by venue?

Yes, you’d use with the same filter above or FHEE__Events_Admin_Page__get_events__where which is applies specific to the where conditions right before the other filter:

$where          = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $request_params);
        $query_params   = apply_filters(
            'FHEE__Events_Admin_Page__get_events__query_params',
            [
                $where,
                'limit'    => $limit,
                'order_by' => $orderby,
                'order'    => $order,
                'group_by' => 'EVT_ID',
            ],
            $request_params
        );

Either of those can be used to add additional conditions when searching.


weblinxinc

November 22, 2024 at 2:14 pm

Thanks, I’ve got the default sorting working, but struggling with pretty much everything else…

In FHEE__Events_Admin_Page__get_events__where, how can I specify “NOT IN” or “!=”? I want to query for all events that are not in a specific category, but I can’t figure out how to do this:


add_filter("FHEE__Events_Admin_Page__get_events__where", function (array $where): array {
if (! (array_key_exists("Term_Taxonomy.term_id", $where) && $where["Term_Taxonomy.term_id"] === 869)) {
$where = [
"Term_Taxonomy.taxonomy" => "espresso_event_categories",
"Term_Taxonomy.term_id" => 869,
"Term_Taxonomy.operator" => "NOT IN", // this leads to an error
];
}

return $where;
});


weblinxinc

November 22, 2024 at 2:56 pm

1. The filters on the “Overview” page don’t seem to be working correctly; for “Select a Month/Year” we only see “September 2025,” but there are many events in other months.

Hmm, strange.

Have those events been published?

Is this with no other filters applied?

Yeah, usually the dates don’t even populate. I’ve seen it show one month, but right now it shows “Select a Month/Year” with no options. This is with no other filters applied.


weblinxinc

November 22, 2024 at 3:03 pm

Similarly for the venue filtering, I just don’t understand how your hooks work. Can you provide me an example of how I’d filter the results using the FHEE__Events_Admin_Page__get_events__where hook? Is there any way for me to just feed it a direct SQL query so I can cross-relate the data as I need to?


Tony

  • Support Staff

November 25, 2024 at 3:46 am

Sorry, I assumed you’d reviewed our model system previously so I didn’t provide details on using them.

For this…

In FHEE__Events_Admin_Page__get_events__where, how can I specify “NOT IN” or “!=”? I want to query for all events that are not in a specific category, but I can’t figure out how to do this.

You need to review this doc:

https://github.com/eventespresso/event-espresso-core/blob/master/docs/G–Model-System/model-query-params.md#different-operators

In short this:

"Term_Taxonomy.operator" => "NOT IN", // this leads to an error

.operator doesn’t exist on the EE models, you pass it as part of the term_id parameter itself:

"Term_Taxonomy.term_id" => ['NOT_IN', [869]],

(NOT_IN expects an array of values, even just 1)

Side note – your code is currently completely replacing ALL values of WHERE with the code to just exclude the category, meaning if anything else is set it’ll be replaced/ignored.

Similarly for the venue filtering, I just don’t understand how your hooks work. Can you provide me an example of how I’d filter the results using the FHEE__Events_Admin_Page__get_events__where hook?

I’ll need more details on what you doing with venues to give you an example. However, the best example I can give you here is to point you to how the current filters work.

If you search our codebase for FHEE__Events_Admin_Page__get_events__where you’ll find where that filter is applied, it’s in \event-espresso-core-reg\admin_pages\events\Events_Admin_Page.core.php.

Within that class you’ll see this code for filtering by Venue:

// filter events by venue.
$venue = $this->request->getRequestParam('venue', 0, DataType::INT);
if ($venue) {
    $where['Venue.VNU_ID'] = $venue;
}

If a venue (ID) is set pass that to the model for the related Venue.VNU_ID.

All of the model query params work in the same way so once you follow how those params work you can apply it to pretty much every model/query you want… without in-depth knowledge of the joins going on in the background.

Is there any way for me to just feed it a direct SQL query so I can cross-relate the data as I need to?

No, the models handle all of the various joins, converting the params to the correct DB columns, etc. Ultimately they use wpdb so if you really wanted to dig that deep you could but I don’t advise it, or support it.

The models make querying EE data much easier and you can do some really powerful querying with ver minimal code, I highly recommend browsing the above docs, the time taken will be a huge timesaver when working with EE data.

https://github.com/eventespresso/event-espresso-core/tree/master/docs/G–Model-System


Tony

  • Support Staff

November 25, 2024 at 4:06 am

Yeah, usually the dates don’t even populate. I’ve seen it show one month, but right now it shows “Select a Month/Year” with no options. This is with no other filters applied.

I’ve separated this out into another reply as it’s not related to the filtering above.

This is strange and will need some investigation.

If you don’t have it already installed Query Monitor:

https://en-gb.wordpress.org/plugins/query-monitor/

Then go to EE -> Events.

Open query monitor from the admin bar.

Go to Database Queries.

Filter caller by – EEM_Base->_process_wpdb_query()

Component by – Plugin: event-espresso-core-reg

Search the queries for esp_datetime AS Datetime

When you find one that looks like this:

https://monosnap.com/file/KifCI7C4RxRlDwOZUWGTxdLUT5S8aR

Open up the caller and confirm it’s from the EEH_Form_Fields::generate_event_months_dropdown() call.

What is the query there?

By default it should be:

SELECT YEAR(DATE_ADD(DTT_EVT_start, INTERVAL 0 HOUR)) AS dtt_year, MONTHNAME(DATE_ADD(DTT_EVT_start, INTERVAL 0 HOUR)) AS dtt_month, MONTH(DATE_ADD(DTT_EVT_start, INTERVAL 0 HOUR)) AS dtt_month_num
FROM wp_esp_datetime AS Datetime
LEFT JOIN wp_posts AS Event_CPT
ON Event_CPT.ID=Datetime.EVT_ID
LEFT JOIN wp_esp_event_meta AS Event_Meta
ON Event_CPT.ID = Event_Meta.EVT_ID
WHERE Datetime.DTT_deleted = 0
AND ( (Event_CPT.post_type = 'espresso_events'))
AND Event_CPT.post_status NOT IN ('trash')
GROUP BY dtt_year, dtt_month
ORDER BY Datetime.DTT_EVT_start DESC

Try running that directly, do you get results from the query?


weblinxinc

November 25, 2024 at 8:03 am

Thanks, I’ll look in to these items today, I appreciate the help.

When I run that SQL query, I get this response:

#1055 - Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'mytablename.Datetime.DTT_EVT_start' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by


weblinxinc

November 25, 2024 at 8:06 am

This link 404s for me, I’m assuming this stuff’s not available publicly https://github.com/eventespresso/event-espresso-core/blob/master/docs/G–Model-System/model-query-params.md#different-operators

Side note – your code is currently completely replacing ALL values of WHERE with the code to just exclude the category, meaning if anything else is set it’ll be replaced/ignored.

Is there a way to convert it to an array of conditions then, so I can keep existing conditions while appending my own?


weblinxinc

November 25, 2024 at 8:14 am

Apologies for the third response:

By filtering by venue, I mean that we want to allow an administrator to enter, for example, “Chicago, IL” and find all events associated to that location. This would be in the “All Events” dashboard area.

And here’s what the query looks like for the “generate_event_months_dropdown” call on the dashboard.

SELECT YEAR(DATE_SUB(DTT_EVT_start, INTERVAL 6 HOUR)) AS dtt_year, MONTHNAME(DATE_SUB(DTT_EVT_start, INTERVAL 6 HOUR)) AS dtt_month, MONTH(DATE_SUB(DTT_EVT_start, INTERVAL 6 HOUR)) AS dtt_month_num
FROM wp_esp_datetime AS Datetime
LEFT JOIN wp_posts AS Event_CPT
ON Event_CPT.ID=Datetime.EVT_ID
LEFT JOIN wp_esp_event_meta AS Event_Meta
ON Event_CPT.ID = Event_Meta.EVT_ID
WHERE Datetime.DTT_deleted = 0
AND ( (Event_CPT.post_type = 'espresso_events'))
AND Event_CPT.post_status = 'draft'
GROUP BY dtt_year, dtt_month
ORDER BY Datetime.DTT_EVT_start DESC


Tony

  • Support Staff

November 25, 2024 at 8:55 am

This link 404s for me, I’m assuming this stuff’s not available publicly https://github.com/eventespresso/event-espresso-core/blob/master/docs/G–-Model-System/model-query-params.md#different-operators

No, it’s public but I remember this happening previously.

The forum is escaping the --, so the link is:

https://github.com/eventespresso/event-espresso-core/blob/master/docs/G--Model-System/model-query-params.md#different-operators

Is there a way to convert it to an array of conditions then, so I can keep existing conditions while appending my own?

It is already an array, but your code replaces the current variable with your own array instead of adding/replacing the values within it:

$where = [...]

Replace $where with your new array.

Vs:


$where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
$where['Term_Taxonomy.term_id'] = ['NOT_IN', [869]];

Adds additional elements to the current array, replacing them if already set. There may be other elements set within where that you’ll want to keep.

By filtering by venue, I mean that we want to allow an administrator to enter, for example, “Chicago, IL” and find all events associated to that location. This would be in the “All Events” dashboard area.

Oh for the search value you mean?

Take a look in event-espresso-core\admin_pages\events\Events_Admin_Page.core.php to see how EE adds the search parameters to the where condition.

And here’s what the query looks like for the “generate_event_months_dropdown” call on the dashboard.

That looks valid, what happens when you run that SQL?


weblinxinc

December 9, 2024 at 9:29 am

Thanks, I’m trying to pick this up again this week…

Regarding the Month/Year filtering, when I run that SQL query directly in phpMyAdmin, I get this error:

`
#1055 – Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘register875576wz_w1ckl4nd3r.Datetime.DTT_EVT_start’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
`

I’ll look in to the other items and report back.


Tony

  • Support Staff

December 9, 2024 at 9:51 am

Oh yeah! You’ll get that with the above query when ONLY_FULL_GROUP_BY mode is set within the DB… WordPress disables it when running queries.

Can you send me a copy of the wp_esp_datetime table?


weblinxinc

December 9, 2024 at 10:29 am

This reply has been marked as private.


weblinxinc

December 9, 2024 at 11:04 am

Okay, an update on everything so far…

I was able to get searches to include venue names with this:

/**
 * Modify event dashboard search to include venue name
 */
add_filter("FHEE__Events_Admin_Page__get_events__where", function (array $where): array {
    /**
     * Ensure it's the Event Espresso dashboard
     */
    if (! (isset($_GET["page"]) && $_GET["page"] === "espresso_events")) {
        return $where;
    }

    /**
     * Ensure it's a search
     */
    if (! (isset($_GET["s"]) && $_GET["s"])) {
        return $where;
    }

    /**
     * Ensure the "OR" key exists
     */
    if (! array_key_exists("OR", $where)) {
        return $where;
    }

    /**
     * Append the _esp_venue meta key to the search
     */
    $where["OR"]["Venue.VNU_name"] = ["LIKE", "%" . sanitize_text_field($_GET["s"]) . "%"];

    return $where;
});

Works perfectly as far as I can tell.

Next, I was able to figure out how to filter out events with a specific category, but it only works if the event is *only* in that category. That’s fine with me, but my client might complain; is there any way to adjust this to exclude these events even if they’re in other categories?

/**
 * Exclude events in espresso_event_categories = 869 from the Event Espresso dashboard
 */
add_filter("FHEE__Events_Admin_Page__get_events__where", function (array $where): array {
    if (isset($_GET["EVT_CAT"])) {
        return $where;
    }

    $where["Term_Taxonomy.taxonomy"] = "espresso_event_categories";
    $where["Term_Taxonomy.term_id"]  = ["NOT IN", [869]];

    return $where;
});

Sorting events in the dashboard by date was easily done with this:

`php
/**
* Sort Event Espresso dashboard by start date
*/
add_filter(“FHEE__Events_Admin_Page__get_events__query_params”, function (array $params): array {
return array_merge($params, [
“order_by” => “Datetime.DTT_EVT_start”,
]);
});
`

I’ve also got event dates mostly showing up throughout the checkout process, but is there any way to add them to the invoices such as https://example.com/?ee=msg_url_trigger&snd_msgr=html&gen_msgr=html&message_type=invoice&context=purchaser&token=1-8678fc8fef3c4c41e8a0802a3ebc97e4&GRP_ID=14&id=185

Here’s how I’m displaying the date otherwise:

/**
 * Display event dates during the checkout process
 *
 * @param string $value
 * @param EE_Line_Item $line_item
 * @return string
 */
function pofo_child_event_espresso_insert_date(string $value, EE_Line_Item $line_item): string {
    if (($event = $line_item->ticket_event()) && ($date = pofo_child_event_espresso_event_get_date_range($event->ID(), "F j, Y"))) {
        $value = "{$date}<br />{$value}";
    }

    return $value;
}
add_filter("FHEE__EE_Event_Cart_Line_Item_Display_Strategy___ticket_row__name_and_desc", "pofo_child_event_espresso_insert_date", 10, 2);
add_filter("FHEE__EE_Default_Line_Item_Display_Strategy__item_row__name", "pofo_child_event_espresso_insert_date", 10, 2);
add_filter("FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name", "pofo_child_event_espresso_insert_date", 10, 2);

Think that’s all for now…


Tony

  • Support Staff

December 10, 2024 at 1:26 pm

Just a couple of notes from the above:

add_filter("FHEE__Events_Admin_Page__get_events__where", function (array $where)...

The current Request Params are passed to the filter as a 2nd parameters, so against whilst there’s nothing technically wrong with using $_GET, why not use the values from $request_params?

So: add_filter("FHEE__Events_Admin_Page__get_events__where", function (array $where, $request_params)

Then:

/**
 * Ensure it's the Event Espresso dashboard
*/
if (! (isset($_GET["page"]) && $_GET["page"] === "espresso_events")) {
    return $where;
}

Nothing wrong with this per say, but that hook will only ever fire on that specific request, so this will work but is redundant.

Why check for OR:

/**
 * Ensure the "OR" key exists
*/
if (! array_key_exists("OR", $where)) {
    return $where;
}

If its a search request (which is what sets OR) you want to add your own search params. A search request will always have OR set unless something else has filtered the request to remove it… in which case you now don’t want to include Venue Name as a search param?

/**
* Exclude events in espresso_event_categories = 869 from the Event Espresso dashboard
*/

Again, I’d recommend using $request_params, and why not include this is the initial function? You can separate them out but if always altering that query I’d use one for them all. Personal preference more than anything though.

Next, I was able to figure out how to filter out events with a specific category, but it only works if the event is *only* in that category. That’s fine with me, but my client might complain; is there any way to adjust this to exclude these events even if they’re in other categories?

Do you mean when selecting another category to show in the table or just in general?

Any vent set in in more than one category will still display when excluding one of the categories with the above?

/**
* Sort Event Espresso dashboard by start date
*/

Nice.

I’ve also got event dates mostly showing up throughout the checkout process, but is there any way to add them to the invoices …

Can you link me to an invoice and highlight where you’d like to add them? I’ll check into this from there.

Viewing 22 reply threads

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

Event Espresso