After a listing is submitted, GeoDirectory stays on the Add Listing page and shows a message with a link to view or preview the listing. There’s no setting to change this, but a short snippet can send the user to any page you choose.
The snippet
Add this with the Code Snippets plugin or in your child theme’s functions.php, and change the URL:
/**
* Redirect to a page after the GeoDirectory add listing form is submitted.
*/
function my_gd_redirect_after_submit( $message, $post_data ) {
// Only redirect new listings, not edits of existing ones.
if ( ! empty( $post_data['post_parent'] ) ) {
return $message;
}
$redirect_to = home_url( '/thank-you/' ); // Change this.
$message .= '<script>window.location.href = ' . wp_json_encode( $redirect_to ) . ';</script>';
return $message;
}
add_filter( 'geodir_ajax_save_post_message', 'my_gd_redirect_after_submit', 100, 2 );
How it works
The form is saved over AJAX, and geodir_ajax_save_post_message filters the message shown afterwards. The snippet adds a small script to that message, so the browser goes to your URL as soon as the message loads.
$post_data includes the listing ID and post_status. You can use them to send people somewhere different, for example straight to their new listing with get_permalink( $post_data['ID'] ) when the status is publish. A pending listing has no public page yet, so use a thank you page for listings that need review.
Remove the post_parent check if you also want to redirect after someone edits a listing.