ninja_forms_email_user

The Ninja Forms ninja forms email user function.

Description

ninja_forms_email_user(); 

Usage

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

Defined (1)

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

/deprecated/includes/deprecated.php  
  1. function ninja_forms_email_user() { 
  2. global $ninja_forms_processing; 
  3.  
  4. do_action( 'ninja_forms_email_user' ); 
  5.  
  6. $form_ID = $ninja_forms_processing->get_form_ID(); 
  7. $form_title = $ninja_forms_processing->get_form_setting('form_title'); 
  8. $user_mailto = array(); 
  9. $all_fields = $ninja_forms_processing->get_all_fields(); 
  10. if(is_array($all_fields) AND !empty($all_fields)) { 
  11. foreach($all_fields as $field_id => $user_value) { 
  12. $field_row = $ninja_forms_processing->get_field_settings( $field_id ); 
  13.  
  14. if(isset($field_row['data']['send_email'])) { 
  15. $send_email = $field_row['data']['send_email']; 
  16. }else{ 
  17. $send_email = 0; 
  18.  
  19. if($send_email) { 
  20. array_push($user_mailto, $user_value); 
  21.  
  22. $email_from = $ninja_forms_processing->get_form_setting('email_from'); 
  23. $email_from_name = $ninja_forms_processing->get_form_setting( 'email_from_name' ); 
  24. $email_type = $ninja_forms_processing->get_form_setting('email_type'); 
  25. $subject = $ninja_forms_processing->get_form_setting('user_subject'); 
  26. $message = $ninja_forms_processing->get_form_setting('user_email_msg'); 
  27. $default_email = get_option( 'admin_email' ); 
  28.  
  29. if(!$subject) { 
  30. $subject = $form_title; 
  31. if(!$message) { 
  32. $message = __('Thank you for filling out this form.', 'ninja-forms'); 
  33. if(!$email_from) { 
  34. $email_from = $default_email; 
  35. if(!$email_type) { 
  36. $email_type = ''; 
  37.  
  38. if( $email_type !== 'plain' ) { 
  39. $message = apply_filters( 'ninja_forms_user_email_message_wpautop', wpautop( $message ) ); 
  40.  
  41. $email_from = $email_from_name.' <'.$email_from.'>'; 
  42.  
  43. $email_from = htmlspecialchars_decode($email_from); 
  44. $email_from = htmlspecialchars_decode($email_from); 
  45.  
  46. $headers = array(); 
  47. $headers[] = 'From: '.$email_from; 
  48. $headers[] = 'Content-Type: text/'.$email_type; 
  49. $headers[] = 'charset=utf-8'; 
  50.  
  51. $attachments = false; 
  52. if ( $ninja_forms_processing->get_form_setting( 'user_attachments' ) ) { 
  53. $attachments = $ninja_forms_processing->get_form_setting('user_attachments'); 
  54.  
  55. if ( is_array( $user_mailto ) AND ! empty( $user_mailto ) ) { 
  56. // check to make sure there's an attachment before attaching one 
  57. if ( $attachments ) { 
  58. wp_mail( $user_mailto, $subject, $message, $headers, $attachments ); 
  59. } else { 
  60. wp_mail( $user_mailto, $subject, $message, $headers ); 
  61.