nf_remove_old_email_send_to

Removes old email settings form a single form.

Description

nf_remove_old_email_send_to( $form_id ); 

Parameters (1)

0. $form_id
The form id.

Usage

  1. if ( !function_exists( 'nf_remove_old_email_send_to' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ninja-forms/deprecated/includes/admin/upgrades/upgrade-functions.php'; 
  3.  
  4. // The form id. 
  5. $form_id = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = nf_remove_old_email_send_to($form_id); 
  9.  

Defined (1)

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

/deprecated/includes/admin/upgrades/upgrade-functions.php  
  1. function nf_remove_old_email_send_to( $form_id ) { 
  2. if ( empty ( $form_id ) ) 
  3. return false; 
  4.  
  5. // Remove any "Admin mailto" settings we might have. 
  6. $form_row = ninja_forms_get_form_by_id( $form_id ); 
  7.  
  8. if ( isset ( $form_row['data']['admin_mailto'] ) ) { 
  9. unset ( $form_row['data']['admin_mailto'] ); 
  10.  
  11. $args = array( 
  12. 'update_array' => array( 
  13. 'data' => serialize( $form_row['data'] ),  
  14. ),  
  15. 'where' => array( 
  16. 'id' => $form_id,  
  17. ),  
  18. ); 
  19.  
  20.  
  21.  
  22. // Update any old email settings we have. 
  23. $fields = Ninja_Forms()->form( $form_id )->fields; 
  24.  
  25. // Create a notification for our user email 
  26. if ( ! empty ( $fields ) ) { 
  27. foreach ( $fields as $field_id => $field ) { 
  28. if ( isset ( $field['data']['send_email'] ) && $field['data']['send_email'] == 1 ) { 
  29. // Add this field to our $addresses variable. 
  30. unset( $field['data']['send_email'] ); 
  31. unset( $field['data']['replyto_email'] ); 
  32. unset( $field['data']['from_name'] ); 
  33.  
  34. $args = array( 
  35. 'update_array' => array( 
  36. 'data' => serialize( $field['data'] ),  
  37. ),  
  38. 'where' => array( 
  39. 'id' => $field_id,  
  40. ),  
  41. ); 
  42.