Public Ticket #2843677

Redirect after registration (with and without required approval)

Closed
Comments
11 Tickets 4
Orlando started the conversation 5 years ago on August 6, 2021 at 10:50pm

Hi! I'm really enjoying your plugin, I'm still learning, very complex ;)

Can I redirect to a custom page or with the Elementor edit this endpoint?

I would like to explain better, for me this message seems very Cold.
:D

Is it also possible to edit this text?


Ahhh it should be different for those who have successfully registered from those who still need to be approved.



Thank you!


5317021792.png
2,762
KingsPlugins replied 5 years ago on August 7, 2021 at 8:33pm

Hi Orlando,

Glad you're enjoying the plugin,

You can redirect to a custom page after registration by using a PHP code snippet such as this one:

add_filter( 'woocommerce_registration_redirect', 'fd_registration_redirect', 10, 1 );
function fd_registration_redirect($url) {
    return site_url().'/yourcustompage/?redir=1';
}

To add a snippet: https://b2bkingplugin.com/docs/how-to-add-a-snippet-php-or-js/

You can edit that text by translating it (Even if it's the same language, for example English -> English, you can create a translation and use that to edit text). You can do it with a plugin like Loco Translate: https://b2bkingplugin.com/docs/how-to-translate-b2bking-to-any-language-localization/#4-toc-title

By default:

- If approval is needed, a message is shown

- If approval is not needed, the user is directly logged in 

Kind regards,

Stefan

1
11 Tickets 4
Orlando replied 5 years ago on August 8, 2021 at 5:43am

Very good!

In this code to redirect to different pages depending on approval?

If you do not need approval, send to /shop

If you need approval, send to /coming-soon



About adding this snippet, can I put directly on functions.php? I'm wearing a son theme to avoid using these plugins



Thank you!



2,762
KingsPlugins replied 5 years ago on August 8, 2021 at 10:33am

Yes, you can add the snippet directly to functions.php


If you want to redirect differently depending on approval, try this snippet:

add_filter( 'woocommerce_registration_redirect', 'fd_registration_redirect', 10, 1 );
function fd_registration_redirect($url) {
    $approved = get_user_meta(get_current_user_id(),'b2bking_account_approved', true);
    if ($approved === 'no' || !is_user_logged_in()){
        return site_url().'/coming-soon/?redir=1';
    } else {
        return site_url().'/shop/?redir=1';
    }
    
}

Tested and it works.

Approval -> Shop

No Approval -> Coming Soon

1

Sign In