ninja_forms_remove_def

The Ninja Forms ninja forms remove def function.

Description

ninja_forms_remove_def(); 

Usage

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

Defined (1)

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

/deprecated/includes/admin/ajax.php  
  1. function ninja_forms_remove_def() { 
  2. global $wpdb, $ninja_forms_fields; 
  3.  
  4. // Bail if we aren't in the admin 
  5. if ( ! is_admin() ) 
  6. return false; 
  7.  
  8. check_ajax_referer( 'nf_ajax', 'nf_ajax_nonce' ); 
  9.  
  10. $field_id = absint( $_REQUEST['field_id'] ); 
  11. $field_row = ninja_forms_get_field_by_id($field_id); 
  12. $field_type = $field_row['type']; 
  13. $def_id = $field_row['def_id']; 
  14. $wpdb->query($wpdb->prepare("DELETE FROM ".NINJA_FORMS_FAV_FIELDS_TABLE_NAME." WHERE id = %d", $def_id)); 
  15. $wpdb->update(NINJA_FORMS_FIELDS_TABLE_NAME, array('def_id' => '' ), array('def_id' => $def_id)); 
  16. $type_name = $ninja_forms_fields[$field_type]['name']; 
  17. header("Content-type: application/json"); 
  18. $array = array ('def_id' => $def_id, 'type_name' => $type_name); 
  19. echo json_encode($array); 
  20.  
  21. die();