I am trying to redirect user after Woocommerce registration. I have tried everything and it is not working.
I have tried some methods found on internet but they didn't work…
When I change 'myaccount' to another permalink it just freezes when you click register.. not sure why.
wp_safe_redirect( apply_filters( 'woocommerce_registration_redirect', wp_get_referer() ? wp_get_referer() : wc_get_page_permalink( 'welcome' ) )
I even tried with the page id
wp_safe_redirect( apply_filters( 'woocommerce_registration_redirect', wp_get_referer() ? wp_get_referer() : wc_get_page_permalink( '1072' ) )
Any help?
WP WooCommerce Redirect is a WordPress plugin to redirect your WooCommerce website after register or login! You can set any custom page or custom redirect according to user role.
You can set user login and register redirection page without any codding knowledge to your WooCommerce website . Your customer reduce time for using this plugin and get their destination easily.
I have developed a plugin for this issue. Also given bellow of raw code for redirect without any plugin.
If you feel comfort to work with plugin or without code? You can download and install my plugin "WP WooCommerce Redirect"
You want to use a filter like this:
Or, specifically to your code:
The correct tested and functional code is:
Code goes in function.php file of your active child theme (or theme)...
Some common redirections urls used in woocommerce:
$redirection_url = get_home_url();
$redirection_url = get_permalink( wc_get_page_id( 'shop' ) );
$redirection_url = wc_get_cart_url();
$redirection_url = wc_get_checkout_url();
$redirection_url = get_permalink( wc_get_page_id( 'myaccount' ) );
$redirection_url = get_permalink( $post_id );
(where
$post_id
is the id of the post or the page)$redirection_url = home_url('/product/ninja/');
If anyone is looking for the Login redirection version that works for the woocommerce my-account login:
Add this filter in theme function file.
Add the filter:
The accepted answer didn’t work for me. What worked for me was this: