Hi we are having an issue where if the customer is registering as a trade (B2B) customer after they submit the request it just redirects them to the home page without giving any indication that it has been successful.
It only happens when they register as a B2B customer as when they register normally the redirect to the thank you page works.
This is the function below we use to redirect the signed up user.
Is there a function we can implement or attach to our current function to redirect correctly if they are a trade customer?
1) "Hi we are having an issue where if the customer is registering as a trade (B2B) customer after they submit the request it just redirects them to the home page without giving any indication that it has been successful."
Normally what should happen is that the user would stay on the "My Account" page and there would be a notification such as "Thank you for registering. Your account is pending approval...".
However we do commonly see an issue where the user is redirected to the home page instead. It's almost always caused by the theme or some plugin which takes over the redirection, so we'd usually recommend deactivating all plugins / theme, to find where the issue is coming from
2) I am not sure why that code would work for most users, but not for B2B users - perhaps because the B2B registration is on a different page.
B2BKing redirects by default to the My Account page, the page which is configured in WooCommerce -> Settings -> Advanced -> My account page. Please make sure the page is indeed selected there in settings.
Another suggestion would be to try adding this code snippet:
Thank you for your patience on this. I think I have found the issue.
In your theme's functions.php there is the following code:
//Redirect to homepage after logout
add_action('wp_logout', 'auto_redirect_after_logout');
function auto_redirect_after_logout() {
wp_redirect(home_url());
exit();
}
By default, when a user registers, WooCommerce logs in the user - B2BKing must log out the user when manual approval is required. So there is basically an immediate log in - log out, and the log out goes to the home_url() based on the above code.
I commented out that code and tested again:
Now as you can see it works and we also get a 'thank you for registering' message there:
And I apologize if I forgot to re-activate some plugins - I keep a list of active plugins so I can reactivate them after testing, but I guess I must have forgot or got things mixed up somehow. Thanks for letting me know.
Hi we are having an issue where if the customer is registering as a trade (B2B) customer after they submit the request it just redirects them to the home page without giving any indication that it has been successful.
It only happens when they register as a B2B customer as when they register normally the redirect to the thank you page works.
This is the function below we use to redirect the signed up user.
Is there a function we can implement or attach to our current function to redirect correctly if they are a trade customer?
__ START CODE __
add_filter('woocommerce_registration_redirect', 'filter_woocommerce_registration_redirect', 10, 1);
function filter_woocommerce_registration_redirect($redirect) {
return get_permalink(wc_get_page_id('registration-thank-you'));
}
__ END CODE __
Hi there,
1) "Hi we are having an issue where if the customer is registering as a trade (B2B) customer after they submit the request it just redirects them to the home page without giving any indication that it has been successful."
Normally what should happen is that the user would stay on the "My Account" page and there would be a notification such as "Thank you for registering. Your account is pending approval...".
However we do commonly see an issue where the user is redirected to the home page instead. It's almost always caused by the theme or some plugin which takes over the redirection, so we'd usually recommend deactivating all plugins / theme, to find where the issue is coming from
2) I am not sure why that code would work for most users, but not for B2B users - perhaps because the B2B registration is on a different page.
Can you please try to replace
with
and see if that helps solve it?
That just increases the priority of the function, so perhaps it can help solve it.
Kind regards,
Stefan
Hi Marcus,
B2BKing redirects by default to the My Account page, the page which is configured in WooCommerce -> Settings -> Advanced -> My account page. Please make sure the page is indeed selected there in settings.
Another suggestion would be to try adding this code snippet:
If none of that helps, my belief is that there is another plugin, or something in the theme that is interfering.
I can look into it directly if you would like. For that, I would need a backend login to your site, or a staging clone site.
Kind regards,
Stefan
Hi Marcus,
I was trying to look into this now but that link doesn't seem to be working for me I'm afraid.
I didn't open it before this. Can you check please?
I am sorry but I am seeing the same issue with that,
You can drop it here as unencrypted - just make sure to mark the message as 'Private'.
Only you and our team has access to this thread.
Thank you for your patience on this. I think I have found the issue.
In your theme's functions.php there is the following code:
By default, when a user registers, WooCommerce logs in the user - B2BKing must log out the user when manual approval is required. So there is basically an immediate log in - log out, and the log out goes to the home_url() based on the above code.
I commented out that code and tested again:
Now as you can see it works and we also get a 'thank you for registering' message there:
Glad to hear that's working,
And I apologize if I forgot to re-activate some plugins - I keep a list of active plugins so I can reactivate them after testing, but I guess I must have forgot or got things mixed up somehow. Thanks for letting me know.