I couldn’t find any redirection URL in my WordPress code and but each time I completes the registration form it redirects to home page again. I need to change the redirection after the registration is complete. I can understand that the following code plays the trick but can any one help me how can I set the redirection to a URL from the below code and which part to replace?
Thanks
if ( 'publish' == $status ) {
wp_safe_redirect( add_query_arg( 'updated', 'true', get_permalink( $campaign ) ) );
exit();
} elseif ( 'submit' == $action ) {
$url = isset ( $edd_options[ 'submit_page' ] ) ? get_permalink( $edd_options[ 'submit_page' ] ) : get_permalink();
$redirect = apply_filters( 'atcf_submit_campaign_success_redirect', add_query_arg( array( 'success' => 'true' ), $url ) );
wp_safe_redirect( $redirect );
exit();
} else {
wp_safe_redirect( add_query_arg( 'preview', 'true', get_permalink( $campaign ) ) );
exit();
}
}
add_action( 'template_redirect', 'atcf_shortcode_submit_process' );
/**
* Redirect submit page if needed.
*
* @since Astoundify Crowdfunding 1.1
*
* @return void
*/
function atcf_shortcode_submit_redirect() {
global $edd_options, $post;
if ( ! is_a( $post, 'WP_Post' ) )
return;
if ( ! is_user_logged_in() && ( isset( $edd_options[ 'submit_page' ] ) && $post->ID == $edd_options[ 'submit_page' ] ) && isset ( $edd_options[ 'atcf_settings_require_account' ] ) ) {
$url = isset ( $edd_options[ 'login_page' ] ) ? get_permalink( $edd_options[ 'login_page' ] ) : home_url();
$url = add_query_arg( array( 'redirect_to' => get_permalink( $edd_options[ 'submit_page' ] ) ), $url );
$redirect = apply_filters( 'atcf_require_account_redirect', $url );
wp_safe_redirect( $redirect );
exit();
}
}
add_action( 'template_redirect', 'atcf_shortcode_submit_redirect', 1 );
You’ve many
wp_safe_redirect
functions.Some outside the
atcf_shortcode_submit_redirect()
and one inside of it.However I’m not sure really based on your code, those outside don’t have anything to do with registration page. So you should change the one that is inside.
and that’s the first
$url
variable:As you can see if there is no option saved before with the name of
login_page
redirection URL will behome_url()
that’s your homepage link.If you wan’t to redirect the user to login page, you’d better go and find this option (somewhere in related plugin/template settings page) and check/fill that option, otherwise change the
home_url()
to whatever local URL you want (e.g."http://mywebsite/successful-page"
)I’m not sure the plugin (or theme) works internally before see the whole code, but I get a bit of sense.
wp_safe_redirect redirects to the given url(string). So try tinkering on that one. Keep copy and change the wp_safe_redirect parameter to ‘https://google.com‘ or something else. Then you will find which conditional statement is triggering and redirecting to your homepage.
I think the atcf_shortcode_submit_redirect function redirects whom didn’t logged in to login page, so it would not relevant to your problem.
i like to use the javascript document.location.
just write an function with single argument inside the function provide javascript code with script tags
I know this is an old post, but in case anyone else is looking for the answer, here’s what I did.
I was able to successfully redirect the user to the profile page by changing the $redirect value. However, when the user logged out, it would stay on the profile page and add the login/register into that page???
Anyways, I installed Peter’s Login Redirect and set only 2 options:
“All Other Users” set the logout URL to the whatever page you want
“Post-Registration URL” set this to the page that should come up after a successful registration