Is it possible to have more than one custom redirect URL after verification?

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #101571
    Toby
    Guest

    Hi there,

    Do you know how I might achieve the following?

    • Aim: Have more than one custom redirect URL after a successful email verification.
    • Behaviours:
      1. If a user’s order contains only one product of the type ‘Simple subscription’ or ‘Variable subscription’, redirect them to a custom URL according to that product’s product ID.
      2. If a user’s order contains more than one subscription product, redirect them to a default URL (the WooCommerce account dashboard in my case).

    Please let me know if you require further information. I look forward to hearing from you.

    Kind regards,

    Toby

    #101572
    Zohaib
    Participant

    Hi Toby,

    Unfortunately, it is not possible to redirect customers to multiple pages after successful verification.

    The redirect on success option is meant to be used to redirect users after successful verification, this can be to the, home page, shop page, or a custom URL such as a thank you page. But it all users will be redirected to the same page.

    #101573
    Toby
    Guest

    Hi Zohaib,

    That’s okay – a single redirect URL is fine. Thank you for confirming that only one is possible.

    Have a good weekend.

    Toby

    #101574
    Pablo
    Moderator
    Plugin Support

    Hi Toby,

    Although this is not possible with the current options from the plugin, this might be possible with some custom code by using the alg_wc_ev_user_account_activated hook. For example:

    add_action( 'alg_wc_ev_user_account_activated', function ( $user_id, $args ) {
       if ( ! $args['directly'] ) {
          return;
       }
       $redirect_url = '';
       $order_id     = get_order_from_user_id( $user_id );
       if (
          1 === get_product_type_qty_from_order( 'simple-subscription', $order_id ) ||
          1 === get_product_type_qty_from_order( 'variable-subscription', $order_id )
       ) {
          $redirect_url = 'http://redirect-to-url-1.com';
       } elseif (
          get_product_type_qty_from_order( 'simple-subscription', $order_id ) > 1 ||
          get_product_type_qty_from_order( 'variable-subscription', $order_id ) > 1
       ) {
          $redirect_url = 'http://redirect-to-url-2.com';
       }
       $redirect_url = add_query_arg( array( 'alg_wc_ev_success_activation_message' => 1 ), $redirect_url );
       wp_redirect( $redirect_url );
       exit;
    }, 90, 2 );
    

    Just a note, the get_order_from_user_id() and get_product_type_qty_from_order() functions do not exist. I just added it as an example.

    #101575
    Toby
    Guest

    Hi Pablo,

    Thank you for that snippet. I see how that could work.

    Best,

    Toby

    #134728
    mohamed hisham
    Participant

    Hi

    for certain reason, after the user click on the verfication link , it direct him again to the cart despite I change the setting to direct the user to home page from
    <table class=”form-table”>
    <tbody>
    <tr valign=”top”>
    <th class=”titledesc” scope=”row”><label for=”alg_wc_ev_redirect_to_my_account_on_success”>Redirect on success</label></th>
    </tr>
    </tbody>
    </table>

    #135019
    pablo-pacheco
    Participant

    Hi,

    In that case, please try to select “Redirect to custom URL” and set the URL right below.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.