Support

Account

Home Forums Bug Reports ACF + bbPress bug

Unread

ACF + bbPress bug

  • There is a bug when using the ACF relationship field along with bbPress.

    The problem: When an Editor or Author level user loads a page that has a relationship field in it, they are unable to see previously selected values. New selections can be made, and saved. However it will overwrite any previous selections, and after updating the page, it will appear as though there are no selections made again.

    Admin level users are able to use relationship fields 100% correctly without any of the above issues.

    This issue has actually existing for a long time now, however there was a working fix available in ACF 4.x which no longer works in ACF 5.x.

    This support forum topic has great information about the issue, and the fix which worked for 4.x:

    http://support.advancedcustomfields.com/forums/reply/13745/

    The acf/get_post_types filter used in that fix is no longer present in ACF 5.x which is why that fix no longer works.

    This could be resolved with a new filter in the acf_get_post_types() function inside of api-helpers.php like so: (note the new ‘acf/exclude_post_types’ filter)

    function acf_get_post_types( $exclude = array(), $include = array() ) {
    	
    	// get all custom post types
    	$post_types = get_post_types();
    	
    	// filter post types
    	$exclude = apply_filters('acf/exclude_post_types', $exclude);
    
    	// core exclude
    	$exclude = wp_parse_args( $exclude, array( 'acf-field', 'acf-field-group', 'revision', 'nav_menu_item' ) );
    	
    	// include
    	if( !empty($include) ) {
    		foreach( array_keys($include) as $i ) {
    			$post_type = $include[ $i ];
    			
    			if( post_type_exists($post_type) ) {	
    				$post_types[ $post_type ] = $post_type;	
    			}	
    		}	
    	}
    	
    	// exclude
    	foreach( array_values($exclude) as $i ) {
    		unset( $post_types[ $i ] );		
    	}
    
    	// return
    	return $post_types;
    }

    This would allow for a similiar fix to the one used in ACF 4.x:

    add_filter( 'acf/exclude_post_types', 'my_acf_post_type_filter' );
    function my_acf_post_type_filter( $exclude ) {
    	
    	$exclude[] = 'topic';
    	$exclude[] = 'reply';
    
    	return $exclude;
    }
Viewing 1 post (of 1 total)

The topic ‘ACF + bbPress bug’ is closed to new replies.