After users submit events on your website using our Community Events plugin, they are directed to an “Event Submitted” page.
But perhaps you’d prefer to redirect users to a different URL after event submission instead. We’ve got a snippet to do just that.
Redirect users with a snippet
You can use the following snippet to redirect users to a different URL after submitting their community event. Modify the following snippet to include the URL where you’d like users to land and add it to your functions.php file.
/**
* Redirect after community submission
*/
function tribe_submission_redirect() {
if( isset($_POST[
'community-event' ]) ) {
// The url to redirect to
$url = "/event-submission-received";
if ( wp_redirect( $url ) ) {
exit;
}
}
}
/** Update required submission fields */
function my_community_required_fields( $fields ) {
if ( ! is_array( $fields ) ) {
return $fields;
}
$fields[] = 'EventURL';
$fields[] = 'post_content';
$fields[] = 'EventStartDate';
$fields[] = 'venue';
$fields[] = 'organizer';
$fields[] = 'EventURL';
return $fields;
}
add_action( 'tribe_events_community_before_event_submission_page_template',
'tribe_submission_redirect' );
add_filter( 'tribe_events_community_required_fields',
'my_community_required_fields',
10,
1 );