bbp_set_user_role doesn’t change role
-
WP version: 5.8.3
bbpress version: 2.6.9
site is in a local environment at the moment.I’m trying to update the role for the users once they enroll in course. I manage to found an entry point for this with “learndash_update_course_access” once there is an update in the user courses list. This part works. What is giving me troubles is the update of the user bbpress roles.
This is the most raw code I try:add_action( 'learndash_update_course_access', 'updatebbpressrole', 20, 4 ); function updatebbpressrole ($user_id, $course_id, $course_access_list, $remove) { $new_role_forum_role = "bbp_blocked"; bbp_set_user_role( $user_id, $new_role_forum_role ); }
I try with a pair of custom roles I have, but it also happens with the basics bbpres roles too, so is not related to the new roles.
Also I try with the update in the root of functions.php this works, sort of, because the update is done, but the select dropdown in the user profile in the admin page get stuck in the old one, but in code the selected one is the updated, if I get out and enter again is fixed.
Any idea about why bbp_set_user_role is not working this way ?
- You must be logged in to reply to this topic.