Skip to:
Content
Pages
Categories
Search
Top
Bottom

bbp_get_caps_for_role filter firing too late and not being processed


  • AITpro
    Participant

    @aitpro

    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;
    	}
    }
Viewing 2 replies - 1 through 2 (of 2 total)

  • Invoke_Media_Group
    Participant

    @invoke_media_group

    bbpress is starting to KILL all my sites that have it. I am thinking it is time to REMOVE this from my sites. Now I cannot even access my sites. This is the error code:

    Warning: ksort() expects parameter 1 to be array, object given in /home/content/p3pnexwpnas06_data03/07/2899307/html/wp-content/plugins/bbpress/includes/core/template-functions.php on line 316

    Can anyone help?


    AITpro
    Participant

    @aitpro

    @invoke_media_group – This forum topic does not have anything to do with your issue/problem. So please create a new forum topic for your different issue/problem. Also you should do standard troubleshooting steps first before posting your new forum topic: deactivate all other plugins to see if another plugin is causing the problem, comment out any custom functions you have created in your theme functions.php file, switch your current theme to a WordPress theme: 2017, 2016… When you post a bbPress forum topic you need to include these things: what WordPress version you have installed, bbPress version you have installed and what troubleshooting steps you have already performed.

    You should also probably include the relevant code in file: /bbpress/includes/core/template-function.php on line 316 (shown below) and that this function: bbp_get_template_stack() uses this filter: bbp_get_template_stack to Call the functions added to the ‘bbp_template_stack’ filter hook, and return an array of the template locations. There is also a related bug here that appears to have already been fixed: https://bbpress.trac.wordpress.org/ticket/2871

    	// Sort.
    	if ( class_exists( 'WP_Hook' ) ) {
    		$filter = $wp_filter[ $tag ]->callbacks;
    	} else {
    		$filter = &$wp_filter[ $tag ];
    
    		if ( ! isset( $merged_filters[ $tag ] ) ) {
    			ksort( $filter );
    			$merged_filters[ $tag ] = true;
    		}
    	}
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar