unregister_meta_key

Unregisters a meta key from the list of registered keys.

Description

unregister_meta_key( (string) $object_type, (string) $meta_key ); 

Parameters (2)

0. $object_type (string)
The type of object.
1. $meta_key (string)
The meta key.

Usage

  1. if ( !function_exists( 'unregister_meta_key' ) ) { 
  2. require_once ABSPATH . WPINC . '/meta.php'; 
  3.  
  4. // The type of object. 
  5. $object_type = ''; 
  6.  
  7. // The meta key. 
  8. $meta_key = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = unregister_meta_key($object_type, $meta_key); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/meta.php  
  1. function unregister_meta_key( $object_type, $meta_key ) { 
  2. global $wp_meta_keys; 
  3.  
  4. if ( ! registered_meta_key_exists( $object_type, $meta_key ) ) { 
  5. return false; 
  6.  
  7. $args = $wp_meta_keys[ $object_type ][ $meta_key ]; 
  8.  
  9. if ( isset( $args['sanitize_callback'] ) && is_callable( $args['sanitize_callback'] ) ) { 
  10. remove_filter( "sanitize_{$object_type}_meta_{$meta_key}", $args['sanitize_callback'] ); 
  11.  
  12. if ( isset( $args['auth_callback'] ) && is_callable( $args['auth_callback'] ) ) { 
  13. remove_filter( "auth_{$object_type}_meta_{$meta_key}", $args['auth_callback'] ); 
  14.  
  15. unset( $wp_meta_keys[ $object_type ][ $meta_key ] ); 
  16.  
  17. // Do some clean up 
  18. if ( empty( $wp_meta_keys[ $object_type ] ) ) { 
  19. unset( $wp_meta_keys[ $object_type ] ); 
  20.  
  21. return true;