Skip to content

Instantly share code, notes, and snippets.

@lorenzocaum
Last active March 24, 2016 14:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lorenzocaum/307016676842e4f5c456 to your computer and use it in GitHub Desktop.
Save lorenzocaum/307016676842e4f5c456 to your computer and use it in GitHub Desktop.
How to add a JavaScript code snippet to the Thank You page for Event Espresso 4

Example 1

<?php
//* Do NOT include the opening php tag

function ee_add_javascript_thank_you() {
	if ( is_page( 'thank-you' ) ) {
		?>
		<script type="text/javascript" src="http://example.com/js"></script>
		<?php
	}	
}
add_action( 'wp_footer', 'ee_add_javascript_thank_you' );

The example above can be added to your child theme's functions.php file or a site specific plugin (https://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/). By default the slug for the thank you page for Event Espresso 4 is set to thank-you. The slug thank-you should be changed to your actual page slug for the thank you page.

Need it to run in the header? Change wp_footer to wp_head and then save changes.

Example 2

<?php
//* Do NOT include the opening php tag

function ee_add_javascript_thank_you_footer() {
		?>
		<script type="text/javascript" src="http://example.com/js"></script>
		<?php
}
add_action( 'AHEE__thank_you_page_overview_template__bottom', 'ee_add_javascript_thank_you_footer' );

The example above can be added to your child theme's functions.php file or a site specific plugin (https://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/). It will add the JavaScript to the end of the overview section of the thank you page for Event Espresso.

@chrawad
Copy link

chrawad commented Sep 11, 2015

great stuff thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment