wp_ajax_delete_meta

Ajax handler for deleting meta.

Description

wp_ajax_delete_meta(); 

Usage

  1. if ( !function_exists( 'wp_ajax_delete_meta' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/ajax-actions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wp_ajax_delete_meta(); 
  7.  

Defined (1)

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

/wp-admin/includes/ajax-actions.php  
  1. function wp_ajax_delete_meta() { 
  2. $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; 
  3.  
  4. check_ajax_referer( "delete-meta_$id" ); 
  5. if ( !$meta = get_metadata_by_mid( 'post', $id ) ) 
  6. wp_die( 1 ); 
  7.  
  8. if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $meta->post_id, $meta->meta_key ) ) 
  9. wp_die( -1 ); 
  10. if ( delete_meta( $meta->meta_id ) ) 
  11. wp_die( 1 ); 
  12. wp_die( 0 );