Okay
  Public Ticket #3516872
Redirect user after completed the form registration
Closed

Comments

  •  4
    Mar started the conversation

    Hello!

    In my store, B2B users require manual approval when completing the registration form. After submitting the registration form, I need to redirect the user to a landing page where they will receive information stating that their account is pending validation. They will also be notified by email once their account is approved.

    How can I set up this redirection for the B2B registration form submission?I haven't found this solution in the documentation.

    I'm awaiting your answer, ASAP.
    Best regards!

  •  2,218
    WebWizards replied

    Hi there,

    It should be possible to do that, by adding this PHP code snippet to your site:

    add_filter('b2bking_manual_approval_redirect_registration', function($url, $user){
        return 'https://yoursite.com/linkurl';
    }, 10, 2);
    

    You'd just need to change the URL to your own,


    A PHP snippet can be added to functions.php, or by following our guide here: https://woocommerce-b2b-plugin.com/docs/how-to-add-a-snippet-php-or-js/



    Kind regards,

    Stefan

  •   Mar replied privately
  •   Mar replied privately
  •  2,218
    WebWizards replied

    Hi again,

    I looked into this now on your site,


    It seems that there's a conflict with the following plugin:

    YITH WooCommerce Customize My Account Page Premium 


    If you deactivate that plugin, you will see registrations redirect to https://blisscare-lab.com/pendiente-validacion-usuario/


    I checked further and it seems it's related to this YITH setting:

    3303980252.png

    If you deactivate it, it then works.


    Kind regards,

    Stefan

  •   Mar replied privately
  •  2,218
    WebWizards replied

    Hi there,

    I believe that that redirect code is causing a conflict. Here is the problem: when B2BKing registers a manual approval user, WooCommerce automatically logs in the user (Standard functionality) - B2BKing must log out the user as we don't want them to be logged in until approval. When B2BKing logs out the user, your redirect code is triggered.



    Please try to change the code to this one:

    add_action('wp_logout','owp_redirect_after_logout', 10, 1);
    function owp_redirect_after_logout($user_id){
        $user_approval = get_user_meta($user_id, 'b2bking_account_approved', true);
        if ($user_approval !== 'no'){
            wp_redirect('https://blisscare-lab.com/');
            exit();
        }
    }
    

    I think that can resolve it.


    Kind regards,

    Stefan


  •   Mar replied privately
  •  2,218
    WebWizards replied

    Hi there,

    My understanding is that the error says you already have the other logout snippet active and it cannot redeclare the function.

    1550177412.png

    You must deactivate the other code snippet with the logout redirect - both should not be active at the same time.