unregister_meta_key

Advertisement

Summery Summery

Unregisters a meta key from the list of registered keys.

Syntax Syntax

unregister_meta_key( string $object_type, string $meta_key, string $object_subtype = '' )

Parameters Parameters

$object_type

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

$meta_key

(Required) Metadata key.

$object_subtype

(Optional) The subtype of the object type.

Default value: ''

Return Return

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

Source Source

File: wp-includes/meta.php

		'default'           => '',
		'single'            => false,
		'sanitize_callback' => null,
		'auth_callback'     => null,
		'show_in_rest'      => false,
	);

	// There used to be individual args for sanitize and auth callbacks.
	$has_old_sanitize_cb = false;
	$has_old_auth_cb     = false;

	if ( is_callable( $args ) ) {
		$args = array(
			'sanitize_callback' => $args,
		);

		$has_old_sanitize_cb = true;
	} else {
		$args = (array) $args;
	}

	if ( is_callable( $deprecated ) ) {
		$args['auth_callback'] = $deprecated;
		$has_old_auth_cb       = true;
	}

	/**
	 * Filters the registration arguments when registering meta.
	 *
	 * @since 4.6.0
	 *
	 * @param array  $args        Array of meta registration arguments.
	 * @param array  $defaults    Array of default arguments.
	 * @param string $object_type Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user',
	 *                            or any other object type with an associated meta table.
	 * @param string $meta_key    Meta key.
	 */

Advertisement

Changelog Changelog

Changelog
Version Description
4.9.8 The $object_subtype parameter was added.
4.6.0 Introduced.

Advertisement

Leave a Reply