bbp_get_caps_for_role filter firing too late and not being processed
-
WordPress 4.7
bbPress 2.5.12
Site: https://forum.ait-pro.com/
Custom bbPress/BuddyPress Theme & tested switching to WP Twenty Seventeen Theme
Tried creating a bug ticket on trac, but was not allowed to login and do so.Issue: In previous versions of bbPress this code below worked fine in my Theme functions.php file. As of bbPress 2.5.12 this code is no longer working in my Theme functions.php file. I checked output and bbPress Core code and did not see anything obvious. Output was good. ie $role and $caps, but it appeared that the filter was not being processed in time when the Activity template loaded. So I moved this code to the BuddyPress /plugins/bp-custom.php file and this code works fine. So obviously this some kind of init or loading order type of issue. ie the filter is being processed too late.
// bbPress Disable Topic Tags for Participants function aitpro_get_caps_for_role_filter( $caps, $role ) { if ( $role == 'bbp_participant' ) $caps = aitpro_get_caps_for_role( $role ); return $caps; } add_filter( 'bbp_get_caps_for_role', 'aitpro_get_caps_for_role_filter', 10, 2 ); function aitpro_get_caps_for_role( $role ) { switch ( $role ) { /* Disable Topic Tags for Participants */ case 'bbp_participant': return array( // Primary caps 'spectate' => true, 'participate' => true, // Forum caps 'read_private_forums' => true, // Topic caps 'publish_topics' => true, 'edit_topics' => true, // Reply caps 'publish_replies' => true, 'edit_replies' => true, // Topic tag caps 'assign_topic_tags' => false, // Using false disables allowing Participants to create Topic Tags ); break; default : return $role; } }
- You must be logged in to reply to this topic.