- Support forum for the Customer Email Verification for WooCommerce.
- This topic has 10 replies, 3 voices, and was last updated 2 years, 6 months ago by
Pablo.
-
AuthorPosts
-
March 2, 2022 at 9:48 pm #101528
Gavin Mair
ParticipantHi,
I have email verification turned on. Currently the user is redirected to ‘/login’ after checkout. Do you know how I can change the redirect to go to a custom URL (‘/welcome’ in my case)?
Please let me know if you require more details.
Kind regards,
Gavin
March 2, 2022 at 10:21 pm #101529Gavin Mair
ParticipantHi,
An update: I am using the following PHP snippet to redirect users back to a custom login form if they log out (instead of the default WooCommerce one at ‘/my-account’). I need a way to change the redirect to a custom URL after the user has completed the WooCommerce checkout. I want to send them to a ‘/welcome’ page where I have a custom message asking them to check their email for a verification link.
add_action('wp_logout', 'redirect_after_logout'); function redirect_after_logout() { $loginURL = get_site_url() . "/login"; wp_redirect($loginURL); exit(); }
March 3, 2022 at 10:06 am #101530Zohaib
ParticipantHi Gavin,
In the plugin’s settings, Advanced > Prevent login after register option has a feature to redirect users.
You can also use the Prevent login after checkout feature to logout users who purchase and show them an activation notice on the “Thank you” page.
Please let me know if both options are not suitable.
March 3, 2022 at 11:48 am #101531Gavin Mair
ParticipantHi Zohaib,
Thank you for getting back to me.
I’ve disabled a ‘thank you’ page customisation that was interfering with this as it’s not longer needed. I have the following settings on the ‘Email Verification > ‘Advanced’ section.
- The redirect for ‘Prevent login after register’ is successfully going to a custom redirect URL of ‘/welcome’.
- After blocking the ‘thank you’ page, users are now redirected to the WooCommerce ‘/my-account’ dashboard (where the login form appears) once they have completed checkout. I now need to change this so they are instead sent to ‘/welcome’.
March 4, 2022 at 9:35 am #101532Gavin Mair
ParticipantHi Zohaib,
I unblocked the WooCommerce order received (‘thank you’) page and was able to redirect to a custom URL by using the
&alg_wc_ev_activate_account_message=323
query parameter that is added when email verification is pending after checkout.Hopefully this is a good way to go about this.
Here is the PHP snippet for other users.
/* About: Email Verification (WPFactory) | Redirect to a custom page from the order received page after WooCommerce checkout. Author: Toby Date: 03/03/2022 */ function td_redirect_when_awaiting_email_verification_on_order_received_page() { // Inspect URL query parameters to detect if verification is pending. global $wp; $page_url_with_query_params = add_query_arg( $_SERVER['QUERY_STRING'], '', home_url( $wp->request ) ); $awaiting_verification = str_contains($page_url_with_query_params, "&alg_wc_ev_activate_account_message=323"); if (is_order_received_page() && $awaiting_verification) { // Do redirect. redirect_to_page("welcome"); } } // Redirect to a page given its slug. function redirect_to_page($pageSlug) { $URL = get_site_url() . "/$pageSlug"; wp_redirect($URL); exit; // wp_redirect() does not exit / die automatically. } // Register the action. add_action('template_redirect', 'td_redirect_when_awaiting_email_verification_on_order_received_page');
March 4, 2022 at 10:55 am #101533Gavin Mair
ParticipantIt seems that the number in
&alg_wc_ev_activate_account_message=
changed from323
to327
. I’m not sure why. What’s the correct number for the following message?‘Thank you for your registration. Your account has to be activated before you can log in. Please check your email.’
March 4, 2022 at 2:41 pm #101534Hi Gavin,
I didn’t test your code yet, but the number after
?alg_wc_ev_activate_account_message=
is supposed to be the user ID.March 4, 2022 at 2:58 pm #101535Gavin Mair
ParticipantHi Pablo,
Oh, it’s the user ID. In that case I’ll just check for the presence of the query parameter (by name) but not take into account its value. That way it will always work.
Please let me know if you spot any flaws in my approach if you test the code.
March 4, 2022 at 4:47 pm #101536I believe there could be a simpler way of getting what you want. If you just want to redirect after checkout, we have a filter for that. This is what you could try:
add_filter( 'alg_wc_ev_redirect_after_checkout', function( $redirect_to, $user_id ){ $redirect_to = get_site_url() . '/welcome'; return $redirect_to; }, 11, 2 );
March 4, 2022 at 7:36 pm #101537Gavin Mair
ParticipantHi Pablo,
Ah, you have a filter for exactly that! Super. Thank you for sending that to me. I had to get something working today but I’ll give that snippet a go.
Does you team plan to write a complete reference to the plugin’s actions and filters etc.? I’d love to see that.
Great job on this plugin. I got it this week and it was very easy to configure. 🙂
Thank you for yours and Zohaib’s help.
Enjoy your weekend!
March 4, 2022 at 8:08 pm #101538Anytime,
Thanks for the kind words. We’d appreciate if you could leave a review here or here if you are enjoying the plugin/support 🙂
We have the developers and FAQ tabs with some info but I know it’s just a little. We have plans to update it over time. By the way, I’m going to update it now with the filter I just sent you 😉
See you. Have a good weekend as well!
-
AuthorPosts
- You must be logged in to reply to this topic.