Hi,
I have read this solution, but I was wondering if I could change the url depending on the parent event-category. When adding this code to the functions.php, the button ‘return to Events lists’ sends me to the domain.com, regardless of the category the event was in.
Does it have to do with the permalinks in anyway?
Any suggestions are welcome. Thanks in advanced!
// change default URL for "Return to Events List"
function ee_mer_change_event_list_url(){
if (has_term( 'courses-seminars', 'espresso_event_categories' ) ){
return 'https://domain.com/courses-seminars/';
} elseif (has_term( 'summerschool', 'espresso_event_categories' ) ) {
return 'https://domain.com/summer-school/';
} else {
return 'https://domain.com/';
}
}
It’s not an issue with permalinks, the problem is that when FHEE__EED_Multi_Event_Registration__set_definitions__events_list_url is fired, there is no post, so has_term() has nothing to work with.
The return to event list is displayed in 2 locations, 1 is on the modal when you add the individual events to the cart which I assume is the link you are wanting to change?
That’s done on an ajax request and has the event ID posted, so you can do something like this:
The solution works just perfect! Thanks a million.
Almost there I hope… two other -related- questions…
1. I have placed 2 courses in my cart, one from the category ‘summerschool’ and another from the category ‘courses and seminars’. When looking in my cart through -let’s say- the widget ‘EE Mini cart widget’, there is another button ‘return to events list’ which sends me to the url from ‘event slug’ (EE4 > events > templates > event listing url). Is it possible that the button ‘return to events list’ returns me to the page with the events from the category that I last used or added?
2. Is there a way to add a specific sidebar to ‘single-espresso_events.php’ in my child theme, depending on the ‘espresso_event_categories’:
sidebar ‘summer school’ for espresso_event_category ‘summerschool’ and
sidebar ‘courses & seminars’ for espresso_event_category ‘summerschool’
1. I have placed 2 courses in my cart, one from the category ‘summerschool’ and another from the category ‘courses and seminars’. When looking in my cart through -let’s say- the widget ‘EE Mini cart widget’, there is another button ‘return to events list’ which sends me to the url from ‘event slug’ (EE4 > events > templates > event listing url). Is it possible that the button ‘return to events list’ returns me to the page with the events from the category that I last used or added?
Possible, yes, however we don’t have any examples of how to do it.
You’ll need to dig into the EE_Registry::instance()->SSN->checkout() object to pull the data you need.
2. Is there a way to add a specific sidebar to ‘single-espresso_events.php’ in my child theme, depending on the ‘espresso_event_categories’:
sidebar ‘summer school’ for espresso_event_category ‘summerschool’ and
sidebar ‘courses & seminars’ for espresso_event_category ‘summerschool’
Sure, if you are within single-espresso_events.php you’ll have Post object which means you can pull the current term and include any sidebar you want.
I can’t walk through all of the code to do this so is there a particular part you a stuck on?
Ok, so within your custom template your not calling any of the EE templates and just using it to change the layout of the page, correct?
Event Espresso injects the event details into the_content call but if you are using a custom template (single-espresso_events.php or archive-espresso_events.php) then it automatically assumes your are taking full control over the output and calling each specific section yourself.
In your template you are not doing that so you can add:
Hi Tony,
The piece of code you suggested to use in the functions.php of the child theme add_filter('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', '__return_true' );was already included on line 13. So I don’t know what my next step should be to show the ticket selector on the single events.
Another question.
How can I change the url of the button ‘return to events list’?
I have this code already in a custom plugin, but it doesn’t work on the registration checkout page:
//Filter to change the URL for the "Back to List" button from the Multi Event Registration cart. Event Espresso 4 + Multi Event Registration
// Event espresso
// change default URL for "Return to Events List"
function tw_ee_mer_change_event_list_url_from_term($default_event_list){
// Check if this is an ajax request.
if (wp_doing_ajax()){
// Check we have an event id.
if (!empty($_POST['tkt-slctr-event-id'])) {
$EVT_ID = absint($_POST['tkt-slctr-event-id']);
if (has_term( 'courses-seminars', 'espresso_event_categories', $EVT_ID ) ){
return 'https://url/courses-seminars/';
} elseif (has_term( 'summerschool', 'espresso_event_categories', $EVT_ID ) ) {
return 'https://url/summer-school/';
}
}
}
// Return the default event list url.
return $default_event_list;
}
add_filter( 'FHEE__EED_Multi_Event_Registration__set_definitions__events_list_url', 'tw_ee_mer_change_event_list_url_from_term' );
The support post ‘change default URL for "Return to Event list depending on event-category’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.
Support forum for Event Espresso 3 and Event Espresso 4.