I'm sorry for the late reply, I saw your question in the other ticket as well, but we were only now able to get to it. I will reply here and close the other ticket to keep things organized.
You could do that the following way:
1) Go to B2BKing > Registration Roles > Click "Add New" at the top of the page, and create a new role, named something like "Please Select Role":
As a result, your registration form would look like this:
2)
Click "Publish" to save the role and in the role page, the URL will be something like:
In the snippet below, please replace 4225585 with the number you wrote down during step 2)
jQuery(document).ready(function(){
jQuery(document).on('submit','form.woocommerce-form-register',function(e){
// code
let newRole = 'role_4225585';
let selectedRole = jQuery('#b2bking_registration_roles_dropdown').val();
if (selectedRole === newRole){
e.preventDefault();
alert('Please select a user role!');
}
});
});
Users will not be able to register without selecting a role:
With the Registration Roles dropdown on the front facing registration page, how can you set it so the first role is not selected by default?
I need the customer to be forced choose their role and not have one as a default as they may not change it to the correct one.
Hello Melina,
I'm sorry for the late reply, I saw your question in the other ticket as well, but we were only now able to get to it. I will reply here and close the other ticket to keep things organized.
You could do that the following way:
1) Go to B2BKing > Registration Roles > Click "Add New" at the top of the page, and create a new role, named something like "Please Select Role":
As a result, your registration form would look like this:
2)
Click "Publish" to save the role and in the role page, the URL will be something like:
https://demo.woocommerce-b2b-plugin.com/wp-admin/post.php?post=4225585&action=edit
Please write down the number. In this case it is 4225585
3)
Add the following JavaScript snippet to your site's frontend. You can use this plugin or any other snippets plugin to add it: https://wordpress.org/plugins/code-snippets/
In the snippet below, please replace 4225585 with the number you wrote down during step 2)
Users will not be able to register without selecting a role:
Kind Regards,
Stefan
Perfect thank you! :)
All right, if I can help with anything, let me know