Title: get_{$meta_type}_metadata
Published: April 25, 2014
Last modified: May 20, 2026

---

# apply_filters( “get_{$meta_type}_metadata”, mixed $value, int $object_id, string $meta_key, bool $single, string $meta_type )

## In this article

 * [Description](https://developer.wordpress.org/reference/hooks/get_meta_type_metadata/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/hooks/get_meta_type_metadata/?output_format=md#parameters)
 * [More Information](https://developer.wordpress.org/reference/hooks/get_meta_type_metadata/?output_format=md#more-information)
 * [Source](https://developer.wordpress.org/reference/hooks/get_meta_type_metadata/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/get_meta_type_metadata/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/get_meta_type_metadata/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/hooks/get_meta_type_metadata/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/hooks/get_meta_type_metadata/?output_format=md#wp--skip-link--target)

Short-circuits the return value of a meta field.

## 󠀁[Description](https://developer.wordpress.org/reference/hooks/get_meta_type_metadata/?output_format=md#description)󠁿

The dynamic portion of the hook name, `$meta_type`, refers to the meta object type(
blog, post, comment, term, user, or any other type with an associated meta table).

Returning a non-null value will effectively short-circuit the function.

Possible filter names include:

 * `get_blog_metadata`
 * `get_post_metadata`
 * `get_comment_metadata`
 * `get_term_metadata`
 * `get_user_metadata`

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/get_meta_type_metadata/?output_format=md#parameters)󠁿

 `$value`mixed

The value to return, either a single metadata value or an array of values depending
on the value of `$single`. Default null.

`$object_id`int

ID of the object metadata is for.

`$meta_key`string

Metadata key.

`$single`bool

Whether to return only the first value of the specified `$meta_key`.

`$meta_type`string

Type of object metadata is for. Accepts `'blog'`, `'post'`, `'comment'`, `'term'`,`'
user'`, or any other object type with an associated meta table.

## 󠀁[More Information](https://developer.wordpress.org/reference/hooks/get_meta_type_metadata/?output_format=md#more-information)󠁿

The filter must return null if the data should be taken from the database. If it
returns anything else, the [get_metadata()](https://developer.wordpress.org/reference/functions/get_metadata/)
function (and therefore the `get_user_meta`) will return what the filter returns.

## 󠀁[Source](https://developer.wordpress.org/reference/hooks/get_meta_type_metadata/?output_format=md#source)󠁿

    ```php
    $check = apply_filters( "get_{$meta_type}_metadata", null, $object_id, $meta_key, $single, $meta_type );
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/meta.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/meta.php#L664)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/meta.php#L664-L664)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/get_meta_type_metadata/?output_format=md#related)󠁿

| Used by | Description | 
| [get_metadata_raw()](https://developer.wordpress.org/reference/functions/get_metadata_raw/)`wp-includes/meta.php` |

Retrieves raw metadata value for the specified object.

  | 
| [metadata_exists()](https://developer.wordpress.org/reference/functions/metadata_exists/)`wp-includes/meta.php` |

Determines if a meta field with the given key exists for the given object ID.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/get_meta_type_metadata/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.5.0](https://developer.wordpress.org/reference/since/5.5.0/) | Added the `$meta_type` parameter. | 
| [3.1.0](https://developer.wordpress.org/reference/since/3.1.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/hooks/get_meta_type_metadata/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 3 content](https://developer.wordpress.org/reference/hooks/get_meta_type_metadata/?output_format=md#comment-content-2394)
 2.    [leogermani](https://profiles.wordpress.org/leogermani/)  [  9 years ago  ](https://developer.wordpress.org/reference/hooks/get_meta_type_metadata/#comment-2394)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fget_meta_type_metadata%2F%23comment-2394)
     Vote results for this note: 1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fget_meta_type_metadata%2F%23comment-2394)
 4.  Note that although this filter filters the value that will be returned, you do
     not receive the current value as the first parameter.
 5.  You allways receive `null` in the first parameter.
 6.  If your callback returns anything else than null, this is the value that the function
     will return at the end. If you return null, the function will continue to run 
     normally and try to fetch the data from the database (or cache).
 7.   * Actually – you do not “always receive NULL” as the first parameter.While it
        is true that WordPress calls the first (as possibly ONLY) filter in the sequence
        with a NULL $value, you should allow for the possibility that a higher-priority
        filter could be passing down a $value to your filter!To play nice with other
        plug-ins, rather than your filter returning a hard-coded “null” if it decides
        to take no action, it may be appropriate for your filter to return the $value(
        which may be null, or may be the value injected by an earlier filter!)
      * [Andy Schmidt](https://profiles.wordpress.org/andy-schmidt/) [8 years ago](https://developer.wordpress.org/reference/hooks/get_meta_type_metadata/#comment-2626)
 8.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fget_meta_type_metadata%2F%3Freplytocom%3D2394%23feedback-editor-2394)
 9.   [Skip to note 4 content](https://developer.wordpress.org/reference/hooks/get_meta_type_metadata/?output_format=md#comment-content-4704)
 10.   [Steven Lin](https://profiles.wordpress.org/stevenlinx/)  [  5 years ago  ](https://developer.wordpress.org/reference/hooks/get_meta_type_metadata/#comment-4704)
 11. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fget_meta_type_metadata%2F%23comment-4704)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fget_meta_type_metadata%2F%23comment-4704)
 12. Example migrated from Codex:
 13.     ```php
         add_action( 'init', 'wpdocs_init' );
     
         function wpdocs_init() {
         	add_filter( 'get_user_metadata', 'wpdocs_get_foo', 10, 3 );
         }
     
         function wpdocs_get_foo( $check, $object_id, $meta_key ) {
         	if ( 'foo' === $meta_key ) {
         		// Always return an array with your return value.
         		return array( 'bar' );
         	}
     
         	return $check; // Go on with the normal execution in meta.php
         }
         ```
     
 14.  * You shouldn’t return null if the checks don’t pass, return $value. otherwise
        another filter with higher priority will not be able to set the value: ` add_filter('
        get_user_metadata', 'otherplugin_get_foo', 10, 4 ); function otherplugin_get_foo(
        $value, $object_id, $meta_key, $single ) { if ( 'foo' == $meta_key ) { return
        array( 'bar' ); } return $value; // CORRECT if $value is null it will return
        null, if another plugin has already used the same filter to set a value it 
        will return that value; } add_filter( 'get_user_metadata', 'myplugin_get_baz',
        10, 4 ); function otherplugin_get_foo( $value, $object_id, $meta_key, $single){
        if ( 'baz' == $meta_key ) { return array( 'bar' ); } return null; // WRONG!
        THIS WILL OVERRIDE ALL PREVIOUS get_{$meta_type}_metadata FILTERS; } ` Now 
        if you call get_user_meta(1, ‘foo’, true); you will always get null, because
        myplugin_get_baz will override the $value (bar) set by the first otherplugin_get_foo
        filter. Always return the first parameter if you’re not going to edit the value.
      * [gorgdesign](https://profiles.wordpress.org/gorgdesign/) [5 years ago](https://developer.wordpress.org/reference/hooks/get_meta_type_metadata/#comment-4888)
 15.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fget_meta_type_metadata%2F%3Freplytocom%3D4704%23feedback-editor-4704)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fget_meta_type_metadata%2F)
before being able to contribute a note or feedback.