gform_delete_meta

The Gravity Forms gform delete meta function.

Description

gform_delete_meta( $entry_id, (string) $meta_key = '' ); 

Parameters (2)

0. $entry_id
The entry id.
1. $meta_key — Optional. (string) => ''
The meta key.

Usage

  1. if ( !function_exists( 'gform_delete_meta' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'gravity-forms/forms_model.php'; 
  3.  
  4. // The entry id. 
  5. $entry_id = null; 
  6.  
  7. // The meta key. 
  8. $meta_key = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = gform_delete_meta($entry_id, $meta_key); 
  12.  

Defined (1)

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

/forms_model.php  
  1. function gform_delete_meta( $entry_id, $meta_key = '' ) { 
  2. global $wpdb, $_gform_lead_meta; 
  3. $table_name = RGFormsModel::get_lead_meta_table_name(); 
  4. $meta_filter = empty( $meta_key ) ? '' : $wpdb->prepare( 'AND meta_key=%s', $meta_key ); 
  5.  
  6. $wpdb->query( $wpdb->prepare( "DELETE FROM {$table_name} WHERE lead_id=%d {$meta_filter}", $entry_id ) ); 
  7.  
  8. //clears cache. 
  9. $_gform_lead_meta = array();