Filter hook 'get_{$meta_type}_metadata_by_mid'

in WP Core File wp-includes/meta.php at line 838

View Source

get_{$meta_type}_metadata_by_mid

Filter Hook
Description
Short-circuits the return value when fetching a meta field by meta ID. The dynamic portion of the hook name, `$meta_type`, refers to the meta object type (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 hook names include: - `get_post_metadata_by_mid` - `get_comment_metadata_by_mid` - `get_term_metadata_by_mid` - `get_user_metadata_by_mid`

Hook Information

File Location wp-includes/meta.php View on GitHub
Hook Type Filter
Line Number 838

Hook Parameters

Type Name Description
stdClass|null $value The value to return.
int $meta_id Meta ID.

Usage Examples

Basic Usage
<?php
// Hook into get_{$meta_type}_metadata_by_mid
add_filter('get_{$meta_type}_metadata_by_mid', 'my_custom_filter', 10, 2);

function my_custom_filter($value, $meta_id) {
    // Your custom filtering logic here
    return $value;
}

Source Code Context

wp-includes/meta.php:838 - How this hook is used in WordPress core
<?php
 833  	 * @since 5.0.0
 834  	 *
 835  	 * @param stdClass|null $value   The value to return.
 836  	 * @param int           $meta_id Meta ID.
 837  	 */
 838  	$check = apply_filters( "get_{$meta_type}_metadata_by_mid", null, $meta_id );
 839  	if ( null !== $check ) {
 840  		return $check;
 841  	}
 842  
 843  	$id_column = ( 'user' === $meta_type ) ? 'umeta_id' : 'meta_id';

PHP Documentation

<?php
/**
	 * Short-circuits the return value when fetching a meta field by meta ID.
	 *
	 * The dynamic portion of the hook name, `$meta_type`, refers to the meta object type
	 * (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 hook names include:
	 *
	 *  - `get_post_metadata_by_mid`
	 *  - `get_comment_metadata_by_mid`
	 *  - `get_term_metadata_by_mid`
	 *  - `get_user_metadata_by_mid`
	 *
	 * @since 5.0.0
	 *
	 * @param stdClass|null $value   The value to return.
	 * @param int           $meta_id Meta ID.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/meta.php
Related Hooks

Related hooks will be displayed here in future updates.