I want to use registration role for specific redirection. I've seen that I can get registration role of current user using b2bking_registration_role key
But it returns only a key (role_25803215). I need to have registration role label. How can I do that ? Thx
Are you trying to redirect users to different pages after registration, depending on which registration role (which option in the dropdown they chose)?
You could achieve that with a code snippet, as follows:
add_filter( 'woocommerce_registration_redirect', 'custom_redirection_after_registration', 10, 1 );
function custom_redirection_after_registration( $redirection_url ){
// Change the redirection Url
if (isset($_POST['b2bking_registration_roles_dropdown'])){
if ($_POST['b2bking_registration_roles_dropdown'] === 'role_1234'){
$redirection_url = '/page1';
}
if ($_POST['b2bking_registration_roles_dropdown'] === 'role_4567'){
$redirection_url = '/page2';
}
}
return $redirection_url; // Always return something
}
The above snippet redirects role_1234 to the site.com/page1 and redirect role_4567 to site.com/page2
You can edit the above to match your specific roles and pages.
Hello,
I want to use registration role for specific redirection. I've seen that I can get registration role of current user using b2bking_registration_role key
But it returns only a key (role_25803215). I need to have registration role label. How can I do that ? Thx
Hello Jose,
Are you trying to redirect users to different pages after registration, depending on which registration role (which option in the dropdown they chose)?
You could achieve that with a code snippet, as follows:
The above snippet redirects role_1234 to the site.com/page1 and redirect role_4567 to site.com/page2
You can edit the above to match your specific roles and pages.
For clarity, this is a PHP snippet, that 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/
Let me know if that can solve it for you,
Kind regards,
Stefan
Thanks for the answer.
To be more accurate, I want to redirect users after login, depending on which registration role they have.
I have role "Club 1" with its specific url but I need to get role label from current user.
I can use this function :
I've updated my last comment. I didn't notice there was a mistake...
Thank you for clarifying,
In that case, you can change the login redirect based on the registration role label as follows:
Please note that by "label", here I am referring to the title of the registration role (e.g. B2B (requires approval) below):
Kind regards,
Stefan