Remove metabox field with filter

Support General Remove metabox field with filter

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #15522
    Joseph VanTineJoseph VanTine
    Participant

    I'm trying to create a filter so we can remove fields from a metabox.

    This is the function that I have created to it. It returns null as aspected, but the field is still there in the metabox.

    Code:

    
        /**
         * filter fields
         */
        public function syb_filter_fields( $fields ) {
    
            foreach ( $fields as $field ) { 
                
                if ( $field['id'] == 'boat-details' ) {
                    
                    foreach ($field['fields'] as $key => $value) {
                        
                        if ( $value["id"] == 'field-id' ) {
    
                            $value = NULL;
                        
                        }  
                    }
                }
            }
     
            return $fields;
    
        }
    
    #15541
    Anh TranAnh Tran
    Keymaster

    Hi Joseph,

    You can try unset( $field['fields'][$key] ) instead of setting the $value = null. How did you run the function?

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.