• Hello,
    I’m trying to hide empty fields from the email by adding an add filter function in the functions.php. But it doesn’t seems to work.
    Can someone help me on this?

    add_filter( 'wpcf7_posted_data', 'hideEmptyFields' );
    function hideEmptyFields( $posted_data ) {
    
        if( isset( $posted_data['trainee-firstname3'] ) && '' == $posted_data['trainee-firstname3'] )
            unset( $posted_data['trainee-firstname3'] );
    
        if( $posted_data['trainee-name3'] == '' )
            unset( $posted_data['trainee-name3'] );
    
        return $posted_data;
    }

    Simply need to hide as many empty fields as I have:
    [trainee-firstnameX] and [trainee-nameX]

    Thx for your help,
    N

  • The topic ‘Add filter to hide empty fields’ is closed to new replies.