• Resolved Hasaanch

    (@hasaanch)


    Is there a way we can exclude empty fields (the fields that are optional and the user hasn’t filled) from the submissions (from the email).
    e.g If I have a form having text fields
    * Your Height
    * Your Weight

    Let’s say user fills
    Your Height: 5’6
    Your Weight: (empty)

    I want to receive the email as:
    Your Height: 5’6

    But the Email I receive now is:
    Your Height: 5’6
    Your Weight:

    I hope you understand the problem.
    I tried creating the filter

    
    add_filter( 'ninja_forms_submit_data', 'my_ninja_forms_submit_data' );
    
    function my_ninja_forms_submit_data( $form_data ) {
    
     
      foreach( $form_data[ 'fields' ] as $index => $field) { // Field settigns, including the field key and value.
    
        if($field['value'] == "")
        {
            unset($field[$index]);
        }
       
      }
      
      $form_settings = $form_data[ 'settings' ]; // Form settings.
      
      $extra_data = $form_data[ 'extra' ]; // Extra data included with the submission.
      
      return $form_data;
    }
    
    
Viewing 1 replies (of 1 total)
  • Plugin Contributor Justin McElhaney

    (@jmcelhaney)

    You can accomplish this using the Fields Table merge tag {fields_table} This merge tag only returns the fields that have had data entered into them.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.