unregister_meta_key( string $object_type, string $meta_key )

Unregisters a meta key from the list of registered keys.


Description Description


Parameters Parameters

$object_type

(string) (Required) The type of object.

$meta_key

(string) (Required) The meta key.


Top ↑

Return Return

(bool) True if successful. False if the meta key was not registered.


Top ↑

Source Source

File: wp-includes/meta.php

function unregister_meta_key( $object_type, $meta_key ) {
	global $wp_meta_keys;

	if ( ! registered_meta_key_exists( $object_type, $meta_key ) ) {
		return false;
	}

	$args = $wp_meta_keys[ $object_type ][ $meta_key ];

	if ( isset( $args['sanitize_callback'] ) && is_callable( $args['sanitize_callback'] ) ) {
		remove_filter( "sanitize_{$object_type}_meta_{$meta_key}", $args['sanitize_callback'] );
	}

	if ( isset( $args['auth_callback'] ) && is_callable( $args['auth_callback'] ) ) {
		remove_filter( "auth_{$object_type}_meta_{$meta_key}", $args['auth_callback'] );
	}

	unset( $wp_meta_keys[ $object_type ][ $meta_key ] );

	// Do some clean up
	if ( empty( $wp_meta_keys[ $object_type ] ) ) {
		unset( $wp_meta_keys[ $object_type ] );
	}

	return true;
}

Top ↑

Changelog Changelog

Changelog
Version Description
4.6.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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