I'm trying to hide specific menu options from users who are not logged in.
I can see that when you create a Customer Group in B2B King that it creates a new role within Wordpress. I have it setup so that only users who are part of a B2B King Customer Group / Wordpress Role can see specific menu options using a plugin called User Menus.
It all works perfectly. Where it falls apart is when a user signs up, and the admin approves a user for a B2B King Customer Group, for example "Wholesaler" the user's Wordpress Role is not assigned properly and defaults to 'subscriber'. This results in the hidden menu items not being correctly displayed.
Is there a way to automatically sync the Wordpress Role with the selected B2B King Customer Group?
B2BKing does in fact sync the roles with the group (or at least it should).
What may be confusing here is that, in WordPress a user can have multiple roles. The default WordPress interface only shows 1 role (e.g. subscriber or customer, etc). But a user actually can have 3, 4, X roles. This free plugin fixes the interface and correctly shows all roles: https://wordpress.org/plugins/multiple-roles/
Some ideas:
1) I wonder if the problem could be that the plugin you are using to hide the menu items doesn't know how to work with multiple roles.
2) You may have configured it incorrectly.
For example: if you configured it to HIDE the menu for subscribers, and SHOW the menu to the wholesalers role, if the user has both roles then the menu will probably still be hidden.
So we looked into this further and found that B2BKing is overriding the roles assigned in the Registration Field and making everyone part of the group "B2BKing B2C User" by default. When we go to approve the user and change the role to "Wholesaler" both under Wordpress's Roles dropdown and under B2B King's Groups settings then the menus work as expected.
Is there a way to prevent everyone defaulting to "B2BKing B2C User"? We have enabled Settings > Registration > Enable dropdown & fields to show registration roles.
We have "Manual approval for all" turned on as well.
I apologize for the late reply, struggling with time this week.
I am not sure if I understand the issue. If you are manually approving all users, and then the correct role is assigned to the user during the approval process, then what is the issue here? Users cannot login until approved, so I do not see how that impacts the user.
I am thinking this is normal behaviour: users are not actually given the role until you approve them for that role (since you are using Manual Approval for All). I checked the code too and this seems to be the way it was intended.
If you can clarify, I can look further into it. I hope I didn't miss something.
I have seen this too. If you enable the user to create a sub account, then the new user is not asigned the proper user role. I am sure there is a snippet to handle this, I just have not figured it out yet. I love this plugin, and hope there is a solution to this.
Can you kindly please open a separate ticket for this? This is from 2020 and the plugin went through some changes since then.
B2BKing no longer uses WP Roles by default, now it only uses its own groups. The plugin sets all subaccounts WP roles to "customer".
By default the plugin should treat all subaccounts as if they are the parent user (e.g. give them the same permissions as the parent, based on parent group and other settings). It would help if you can create a separate ticket with more details about the issues you're having,
When a customer create a subaccount, that new account does not inherit the role (as it was earlier, from what I have read).
I need to put in restrictions in the menu, for what certain roles are allowed to see/read. it does not wok at his point and I have to figure out a way to solve it. I guess there is a filter that can put a group member into the corresponding user role, but I cannot figure out how to create it though.
These would also be applied to subaccounts (if the subaccount is a child of an account in group XYZ, the body class of group XYZ is also applied for the subaccount).
For further reference, kindly please open a separate ticket with your Envato ID or purchase code, Thank you.
Hi,
I'm trying to hide specific menu options from users who are not logged in.
I can see that when you create a Customer Group in B2B King that it creates a new role within Wordpress. I have it setup so that only users who are part of a B2B King Customer Group / Wordpress Role can see specific menu options using a plugin called User Menus.
It all works perfectly. Where it falls apart is when a user signs up, and the admin approves a user for a B2B King Customer Group, for example "Wholesaler" the user's Wordpress Role is not assigned properly and defaults to 'subscriber'. This results in the hidden menu items not being correctly displayed.
Is there a way to automatically sync the Wordpress Role with the selected B2B King Customer Group?
Hello Sean,
Thank you for purchasing our plugin,
B2BKing does in fact sync the roles with the group (or at least it should).
What may be confusing here is that, in WordPress a user can have multiple roles. The default WordPress interface only shows 1 role (e.g. subscriber or customer, etc). But a user actually can have 3, 4, X roles. This free plugin fixes the interface and correctly shows all roles: https://wordpress.org/plugins/multiple-roles/
Some ideas:
1) I wonder if the problem could be that the plugin you are using to hide the menu items doesn't know how to work with multiple roles.
2) You may have configured it incorrectly.
For example: if you configured it to HIDE the menu for subscribers, and SHOW the menu to the wholesalers role, if the user has both roles then the menu will probably still be hidden.
Let me know your thoughts,
Kind Regards,
Stefan
Hi Stefan,
So we looked into this further and found that B2BKing is overriding the roles assigned in the Registration Field and making everyone part of the group "B2BKing B2C User" by default. When we go to approve the user and change the role to "Wholesaler" both under Wordpress's Roles dropdown and under B2B King's Groups settings then the menus work as expected.
Is there a way to prevent everyone defaulting to "B2BKing B2C User"? We have enabled Settings > Registration > Enable dropdown & fields to show registration roles.
We have "Manual approval for all" turned on as well.
Hello Sean,
I apologize for the late reply, struggling with time this week.
I am not sure if I understand the issue. If you are manually approving all users, and then the correct role is assigned to the user during the approval process, then what is the issue here? Users cannot login until approved, so I do not see how that impacts the user.
I am thinking this is normal behaviour: users are not actually given the role until you approve them for that role (since you are using Manual Approval for All). I checked the code too and this seems to be the way it was intended.
If you can clarify, I can look further into it. I hope I didn't miss something.
Kind Regards,
Stefan
Hi,
I have seen this too. If you enable the user to create a sub account, then the new user is not asigned the proper user role. I am sure there is a snippet to handle this, I just have not figured it out yet.
I love this plugin, and hope there is a solution to this.
Hi Johan,
Can you kindly please open a separate ticket for this? This is from 2020 and the plugin went through some changes since then.
B2BKing no longer uses WP Roles by default, now it only uses its own groups. The plugin sets all subaccounts WP roles to "customer".
By default the plugin should treat all subaccounts as if they are the parent user (e.g. give them the same permissions as the parent, based on parent group and other settings). It would help if you can create a separate ticket with more details about the issues you're having,
Kind regards,
Stefan
Hi,
Thanks for getting back.
When a customer create a subaccount, that new account does not inherit the role (as it was earlier, from what I have read).
I need to put in restrictions in the menu, for what certain roles are allowed to see/read. it does not wok at his point and I have to figure out a way to solve it. I guess there is a filter that can put a group member into the corresponding user role, but I cannot figure out how to create it though.
Can you please advise in the matter?
Kind regards,
Johan
To hide specific content, you can use either the content visibility shortcode, or use CSS and use our plugin's body classes. Both are described here:
https://woocommerce-b2b-plugin.com/docs/shortcode-to-restrict-content-to-b2b-b2c-user-groups-specific-users/
These would also be applied to subaccounts (if the subaccount is a child of an account in group XYZ, the body class of group XYZ is also applied for the subaccount).
For further reference, kindly please open a separate ticket with your Envato ID or purchase code, Thank you.