Support

Home Forums Event Espresso Premium Print button is not working

Print button is not working

Posted: October 5, 2022 at 12:38 pm

Viewing 16 reply threads


CapellaAmersfoort

October 5, 2022 at 12:38 pm

Hi,
7 months ago I had the possibility to print my ticket tickets. But unfortunately the function/snippet stops working. Can you please help?

https://eventespresso.com/topic/print-button-on-ticket-page/
https://gist.github.com/Pebblo/8b5eaeb9c16d89073d64e1b7c8f78e00


CapellaAmersfoort

October 5, 2022 at 12:43 pm

probably due to php upgrade?


CapellaAmersfoort

October 5, 2022 at 12:57 pm

via debugging I get the following

Fatal error: Uncaught Error: Call to undefined function add_filter() in /home/user/scripts/code.php:14
Stack trace:
#0 {main}
  thrown in /home/user/scripts/code.php on line 14


Tony

  • Support Staff

October 5, 2022 at 1:14 pm

Hi there,

probably due to php upgrade?

Which PHP version is your server running?

> Fatal error: Uncaught Error: Call to undefined function add_filter() in /home/user/scripts/code.php:14

Your running code calling WP functions ( add_filter() ) from a script outside of WordPress? May I ask why you have a /scripts/ directory holding custom functions rather than a custom functions plugin?


CapellaAmersfoort

October 5, 2022 at 1:27 pm

This reply has been marked as private.


Tony

  • Support Staff

October 5, 2022 at 1:33 pm

Sorry, I don’t follow.

A random PHP debugger would not have access to the WP functions which explains why you are getting that error there, but how does that tie into your site?


CapellaAmersfoort

October 5, 2022 at 1:36 pm

This reply has been marked as private.


Tony

  • Support Staff

October 5, 2022 at 1:41 pm

That function I wrote… ‘hooks’ into EE using a ‘hook’:

https://www.smashingmagazine.com/2011/10/definitive-guide-wordpress-hooks/

Those are specific to WordPress, so the code has to run ‘within’ WordPress to use those functions. Testing them on a online debugger wont work because it doesn’t know what a hook is, or how it will run.

So that explains the above error and for now, let’s put that aside.

What is happening on your message template when you use the shortcode for the print button?

As in, what do you mean when you say it isn’t working? What happens?


CapellaAmersfoort

October 5, 2022 at 1:49 pm

This reply has been marked as private.


CapellaAmersfoort

October 5, 2022 at 2:39 pm

[PRINT_BUTTON_* title='Print Tickets' text='Klik hier om uw tickets te printen'] is the row I add to my template


Tony

  • Support Staff

October 6, 2022 at 4:33 am

But the last row is the link to print the tickets, but the link is not working

That I can work with πŸ™‚

So, this is due to a change we made in version 4.10.32.p which adds additional sanitation throughout Event Espresso.

I’ve created a ticket for our developers to check into this and see if we can allow that custom function to work again within core.

If you are comfortable with PHP and FTP I can give you some details that will force the shortcode to work again for the time being?


CapellaAmersfoort

October 6, 2022 at 4:36 am

If you are comfortable with PHP and FTP I can give you some details that will force the shortcode to work again for the time being?

Yes, that will be fine! I can give it a try


Tony

  • Support Staff

October 6, 2022 at 4:41 am

Go to \wp-content\plugins\event-espresso-core-reg\core\libraries\messages\defaults\default\html_main_wrapper.template.php

Line 48, change:

<?php echo wp_kses($main_body, AllowedTags::getAllowedTags()); ?>

To be:

<?php echo $main_body; ?>

Note that generally, I don’t recommend editing plugin files at all but the above should get it working for your event, the above change will be lost the next time Event Espresso is updated on the site.


CapellaAmersfoort

October 6, 2022 at 4:52 am

Thank you so much! The description is clear to me. I will try this when I’m home.


CapellaAmersfoort

October 6, 2022 at 5:32 am

Thanks again. I solved the/my problem!


CapellaAmersfoort

October 6, 2022 at 5:37 am

I –> It (your solution) πŸ˜‰


Tony

  • Support Staff

October 6, 2022 at 8:40 am

Awesome, I’m glad it worked for you πŸ™‚

Viewing 16 reply threads

The support post ‘Print button is not working’ 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