Skip Navigation

[Resolved] Configuring multiple roles in Toolset Access changes role for bbPress

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 8 replies, has 3 voices.

Last updated by Waqar 1 year, 1 month ago.

Assisted by: Waqar.

Author
Posts
#2648833

I am trying to:
Configure multiple roles for users in the WP user area of admin. When I select and save, the role for bbPress forums gets cleared out. So, if someone is a bbPress keymaster, then they lose access to the bbPress forums once I save their multiple roles

I expected to see: I expected the issue to not occur since they are different plugins.

#2649169

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Screenshot 2023-10-02 at 09.18.04.png

Hi there

Can I get some more details from you, as I'm not so familiar with the bbPress plugin particulars.

Having installed it on a local test site I can see it adds a separate section about forum roles to the user profile page (screenshot), and it's not possible to assign a role like "keymaster" using the normal WordPress role UI.

Is it necessary to do something specific to have the bbPress roles show up in the normal role UI (which Access expands to allow setting additional roles).

#2649453

What happens is when I change the multiple roles, it removes the assigned role for the forum that you highlighted. It defaults it to participant. In order to change it back, I have to deactivate Toolset Access, set the forum role, save it, then reactivate Toolset Access.

#2649557

Thank you for sharing further details.

I've performed some testing and research and here are my findings.

Both Toolset Access and bbPress store the user's role information in the WordPress standard way. The assigned roles are stored in the 'wp_capabilities' key in a serialized format, in the 'usermeta' table.

But, when multiple non-bbPress user roles are assigned to a user, bbPress doesn't seem to recognize them.

Instead of assigning, multiple non-bbPress user roles, can you consider creating a new custom user role, that combines the capabilities of the multiple non-bbPress user roles that you wanted to attach? This way there will be just one non-bbPress user role and one bbPress user role to attach.

#2649935

I thought of that, but, unfortunately, this site uses LearnDash, which requires the subscriber role. So an instructor would have three roles...one for LD access, one for instructor level access and a third for the bbPress access.

#2650581

I'm currently performing some further tests and will share my recommendations, by the end of the day today.

#2650985

Thank you for waiting as I completed my testing and research.

The main challenge was that 'bbPress' plugin's code is not designed to support multiple user roles.

On my test website, I was able to make it retain the 'bbPress' plugin's user access role, through this custom code:


add_action( 'profile_update', 'custom_user_profile_update', 9999, 3 );
function custom_user_profile_update( $user_id, $oldUserData, $newUserData ) {
	if(!empty($_POST['bbp-forums-role'])) {
		$custom_user = new WP_User( $user_id );
		$custom_user->add_role( $_POST['bbp-forums-role'] );
	}
}

Note: You can include this code snippet in your active child theme's 'functions.php' file.

#2650987

Can I put it in an MU-Plugin?

#2650995

Yes, the code should work from MU-Plugin too.