Support

Home Forums Event Espresso Premium Events still using custom code after removing

Events still using custom code after removing

Posted: May 10, 2016 at 8:00 am


Champeau

May 10, 2016 at 8:00 am

Hello,

Site: registration.kidstage.net

Code that used to work:

// lets you load the ticket selector template from another location

add_action( ‘AHEE_event_details_before_the_content’, ‘check_if_third_party_seller’);
function check_if_third_party_seller() {

global $post;

$post_id = $post -> ID;
$key = ‘3rd_party_registration’;
$alternate_payment_option = get_post_meta($post_id, $key, true);

if ( !empty($alternate_payment_option) ) {
add_filter (‘FHEE__EE_Ticket_Selector__display_ticket_selector__template_path’, ‘my_custom_ticket_selector_template_location’);
}
}

function my_custom_ticket_selector_template_location(){
return get_stylesheet_directory() . ‘/ticket_selector_chart.template.php’;
}

It replaced the actual ticket selector with a button that took the user to a third party registration page. There is a custom field for the event when creating the event. If it is empty it will display the default event registration. If it has anything in the field it will replace registration with the button.

I disabled all caching on host, and I do not have any caching plugins.

I can completely remove this block of code, and yet every single event will still display the third party registration button. It did not do this before. I’m not sure what happened.

Please help. I can’t seem to figure out what happened. I will keep tinkering away, but I hope I can gain some clarity here.

Thanks,

Ben


Champeau

May 10, 2016 at 8:07 am

I’m not sure if there was an update that caused it to act differently. I changed the name of the custom ticket selector template file and it is working again.


Josh

  • Support Staff

May 10, 2016 at 9:56 am

Hi there,
Yeah I’m not sure what happened based on the information you reported here. It sounds like caching if you’ve removed custom code, but it’s still executing.


Tony

  • Support Staff

May 10, 2016 at 12:54 pm

The ticket template is passed to a function called locate_template.

locate_template checks for custom versions of templates that are passed to it.

Some templates (like the ticket selector template) pass the absolute path for the template to the function which means that locate_template has the full location for the template and that was the first location it would check (meaning templates that passed the absolute path could not be overridden from within that function)

In EE 4.8.27 locate_template added another location check before ANY other location was checked. That location was your themes root directory.

So your code above checks if $alternate_payment_option is not empty and if not loads a custom template which just happens to be in the same location that EE will load by default without your code. Meaning EE is loading that code by default.

If you remove or rename the custom ticket template you have in the theme root directory it should work as expected.

The support post ‘Events still using custom code after removing’ 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.

Event Espresso