Skip to content

Instantly share code, notes, and snippets.

@grayayer
Forked from jg314/ce-redirect.php
Created September 29, 2016 17:31
Show Gist options
  • Save grayayer/8265e887b9747313b9ac4dcffb9375a3 to your computer and use it in GitHub Desktop.
Save grayayer/8265e887b9747313b9ac4dcffb9375a3 to your computer and use it in GitHub Desktop.
Events Calendar Community Events: Redirect users to a new page after submission
<?php
/*
* Send visitors who submit events to a different page after submission.
*
* This actually does the redirect. If an event was submitted, and we're about
* to reload the submission page (with a message instead of a form), this will
* redirect the user.
*
* @param WP $wp
* @return void
*/
function wi_redirect_after_community_submission( $wp ) {
if ( isset($wp->query_vars[WP_Router::QUERY_VAR]) && $wp->query_vars[WP_Router::QUERY_VAR] == 'ce-add-route' && !empty($_POST) ) {
wp_safe_redirect( get_permalink( 7607 ) ); // Use the Post ID of the page you want to redirect people to
exit();
}
}
/**
* If a new community event was created add an action to send people to a custom thank you page.
*/
function wi_check_for_community_submission() {
add_action( 'parse_request', 'wi_redirect_after_community_submission', 11, 1 );
}
add_action( 'tribe_community_event_created', 'wi_check_for_community_submission' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment