ninja_forms_filter_email_add_fields

The Ninja Forms ninja forms filter email add fields function.

Description

ninja_forms_filter_email_add_fields( $message ); 

Parameters (1)

0. $message
The message.

Usage

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

Defined (1)

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

/deprecated/includes/deprecated.php  
  1. function ninja_forms_filter_email_add_fields( $message ) { 
  2. global $ninja_forms_processing, $ninja_forms_fields; 
  3.  
  4. $form_id = $ninja_forms_processing->get_form_ID(); 
  5. $all_fields = ninja_forms_get_fields_by_form_id( $form_id ); 
  6. //$all_fields = $ninja_forms_processing->get_all_fields(); 
  7. $tmp_array = array(); 
  8. if( is_array( $all_fields ) ) { 
  9. foreach( $all_fields as $field ) { 
  10. if( $ninja_forms_processing->get_field_value( $field['id'] ) ) { 
  11. $tmp_array[$field['id']] = $ninja_forms_processing->get_field_value( $field['id'] ); 
  12. $all_fields = apply_filters( 'ninja_forms_email_all_fields_array', $tmp_array, $form_id ); 
  13.  
  14. $email_type = $ninja_forms_processing->get_form_setting( 'email_type' ); 
  15. if(is_array($all_fields) AND !empty($all_fields)) { 
  16. if($email_type == 'html') { 
  17. $message .= "<br><br>"; 
  18. $message .= apply_filters( 'nf_email_user_values_title', __( 'User Submitted Values:', 'ninja-forms' ) ); 
  19. $message .= "<table>"; 
  20. }else{ 
  21. $message = str_replace("<p>", "\r\n", $message); 
  22. $message = str_replace("</p>", "", $message); 
  23. $message = str_replace("<br>", "\r\n", $message); 
  24. $message = str_replace("<br />", "\r\n", $message); 
  25. $message = strip_tags($message); 
  26. $message .= "\r\n \r\n"; 
  27. $message .= apply_filters( 'nf_email_user_values_title', __( 'User Submitted Values:', 'ninja-forms' ) ); 
  28. $message .= "\r\n"; 
  29. foreach( $all_fields as $field_id => $user_value ) { 
  30.  
  31. $field_row = $ninja_forms_processing->get_field_settings( $field_id ); 
  32. $field_label = $field_row['data']['label']; 
  33. $field_label = apply_filters( 'ninja_forms_email_field_label', $field_label, $field_id ); 
  34. $user_value = apply_filters( 'ninja_forms_email_user_value', $user_value, $field_id ); 
  35. $field_type = $field_row['type']; 
  36.  
  37. if( $ninja_forms_fields[$field_type]['process_field'] ) { 
  38. if( is_array( $user_value ) AND !empty( $user_value ) ) { 
  39. $x = 0; 
  40. foreach($user_value as $val) { 
  41. if(!is_array($val)) { 
  42. if($x > 0) { 
  43. $field_label = '----'; 
  44. $field_label = apply_filters( 'ninja_forms_email_field_label', $field_label, $field_id ); 
  45. if($email_type == 'html') { 
  46. $message .= "<tr><td width='50%'>".$field_label.":</td><td width='50%'>".$val."</td></tr>"; 
  47. }else{ 
  48. $message .= $field_label." - ".$val."\r\n"; 
  49. }else{ 
  50. foreach($val as $v) { 
  51. if(!is_array($v)) { 
  52. if($x > 0) { 
  53. $field_label = '----'; 
  54. $field_label = apply_filters( 'ninja_forms_email_field_label', $field_label, $field_id ); 
  55. if($email_type == 'html') { 
  56. $message .= "<tr><td width='50%'>".$field_label.":</td><td width='50%'>".$v."</td></tr>"; 
  57. }else{ 
  58. $message .= $field_label." - ".$v."\r\n"; 
  59. }else{ 
  60. foreach($v as $a) { 
  61. if($x > 0) { 
  62. $field_label = '----'; 
  63. $field_label = apply_filters( 'ninja_forms_email_field_label', $field_label, $field_id ); 
  64. if($email_type == 'html') { 
  65. $message .= "<tr><td width='50%'>".$field_label.":</td><td width='50%'>".$a."</td></tr>"; 
  66. }else{ 
  67. $message .= $field_label." - ".$a."\r\n"; 
  68. $x++; 
  69. }else{ 
  70. if($email_type == 'html') { 
  71. $message .= "<tr><td width='50%'>".$field_label.":</td><td width='50%'>".$user_value."</td></tr>"; 
  72. }else{ 
  73. $message .= $field_label." - ".$user_value."\r\n"; 
  74.  
  75. if($email_type == 'html') { 
  76. $message .= "</table>"; 
  77. $message = apply_filters( 'ninja_forms_email_field_list', $message, $form_id ); 
  78.  
  79. return $message;