I have a function for a custom post type that redirects NEW posts to a specific url after they are submitted by users:
function tribe_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(home_url('http://www.example.com'));
exit();
}
}
I want to expand upon this so that when a user UPDATES a post, the user gets redirected to a different url.
So just as I'm testing to see if $wp->query_vars[WP_Router::QUERY_VAR]
is set to ce-add-route
, I need to test against the possibility that it might be set to ce-edit-route
.
How can I edit my function above to achieve that? I'm a novice with php and didn't write the function on my own.
UPDATE: I revised my function and have the ce-edit-route
redirect working, however, the ce-add-route
redirect is no longer working.
function tribe_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(home_url('http://www.example.com/wptest/event-submitted/'));}
elseif ( isset( $wp->query_vars[WP_Router::QUERY_VAR] )
&& $wp->query_vars[WP_Router::QUERY_VAR] == 'ce-edit-route'
&& !empty( $_POST ) ) {
wp_safe_redirect(home_url('http://www.example.com/wptest/event-updated/'));
exit();
}
}