Support

Account

Home Forums Backend Issues (wp-admin) Display Multi Groups From One Taxonomy

Unread

Display Multi Groups From One Taxonomy

  • Hey All,

    I am trying to display multiple custom field group for editing from a custom taxonomy location match. I have it working so it will display one or the other but for some reason not both please help.

    Rule Types

    add_filter('acf/location/rule_types', 'acf_location_rules_types');
    function acf_location_rules_types( $choices ) {
    	
        $choices['Page']['block'] = 'Page Block';
    	return $choices;
    }

    Rule Values

    add_filter('acf/location/rule_values/block', 'acf_location_rule_values_page_type');
    function acf_location_rule_values_page_type( $choices ) {
    	$terms = get_terms( 'block', array(
    		'hide_empty' => false,
    	) );
    
        if( $terms ) {
    	    foreach( $terms as $term ) {
    	        $choices[ $term->term_id ] = $term->name;   
            }
        }
    
        return $choices;
    }

    Rule Match

    add_filter('acf/location/rule_match/block', 'acf_location_rule_match_user', 10, 4);
    function acf_location_rule_match_user( $match, $rule, $options, $field_group )
    {
        $current_user = get_the_terms($_GET['post'], 'block');
        $selected_user = $rule['value'];
    
    	foreach($current_user as $term){
    		if($rule['operator'] == "==")
    		{
    			$match = ( $term->term_id == $selected_user );
        	}
    		if($match == true){ continue; }
        }
        
    
        return $match;
    }

    If anymore infomation is required please let me know.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.