apply_filters( ‘is_protected_meta’, bool $protected, string $meta_key, string $meta_type )

Filters whether a meta key is considered protected.

Parameters

$protectedbool
Whether the key is considered protected.
$meta_keystring
Metadata key.
$meta_typestring
Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user', or any other object type with an associated meta table.

Source

return apply_filters( 'is_protected_meta', $protected, $meta_key, $meta_type );

Changelog

VersionDescription
3.2.0Introduced.

User Contributed Notes

  1. Skip to note 2 content

    Example of 2 meta fields that you want to set as protected:

    function my_meta_is_protected_meta( $protected, $meta_key, $meta_type ) {
    
            switch ($meta_key) {
                    case 'my_first_meta':
                            $protected = true;
                            break;
                    case 'my_second_meta':
                            $protected = true;
                            break;
            }
    
            return $protected;
    }
    add_filter( 'is_protected_meta', 'my_meta_is_protected_meta', 10, 3 );

You must log in before being able to contribute a note or feedback.