• Resolved greenrooster

    (@greenrooster)


    Is there a way to modify the {all_fields} or {all_non_empty_fields} to have them not export as ordered lists? I can get around this by manually inputting all fields I want exported into the email notification, but I would prefer a simpler, more automatic method. I appreciate the help!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Zafer – WPMU DEV Support

    (@wpmudevsupport15)

    Hey there, @greenrooster, thank you for reaching out.

    I was wondering if a table would be a good way of presenting this information? If so, I have found a snippet we created a while back which does exaclty that, it adds the {all_fileds} in a table.

    Please create a new MU plugin file like

    wp-content/mu-plugins/forminator-email-table-view.php

    (just create the /mu-plugins/ folder if it doesn’t exist already)

    and insert in there the exact snippet:

    <?php
    
    add_filter( 'forminator_get_formatted_form_entry', function( $html, $custom_form, $data, $entry, $ignored_field_types ){
    
    $ignored_field_types = Forminator_Form_Entry_Model::ignored_fields();
    
    $form_fields         = $custom_form->get_fields();
    
    $table_rows             = array();
    
    if ( is_null( $form_fields ) ) {
    
    $form_fields = array();
    
    }
    
    foreach ( $form_fields as $form_field ) {
    
    $field_type = $form_field->__get( 'type' );
    
    if ( in_array( $field_type, $ignored_field_types, true ) ) {
    
    continue;
    
    }
    
    $label = $form_field->get_label_for_entry();
    
    $value = render_entry( $entry, $form_field->slug );
    
    $table_rows[ $label ] = $value;
    
    }
    
    $table_head = array_keys( $table_rows );
    
    $table_body = array_values( $table_rows );
    
    array_walk( $table_head, function( &$content, $key ) {
    
    $content = "<th><strong>{$content}</strong></th>";
    
    });
    
    array_walk( $table_body, function( &$content, $key ) {
    
    $content = "<td>{$content}</td>";
    
    });
    
    $html = '<table>';
    
    $html .= "<tr>";
    
    $html .= "<thead>" . implode( '', $table_head ) ."</thead>";
    
    $html .= "<tr>";
    
    $html .= "<tr>";
    
    $html .= "<tbody>" . implode( '', $table_body ) ."</tbody>";
    
    $html .= "<tr>";
    
    $html .= '</table>';
    
    return $html;
    
    }, 20, 5 );

    Let us know how it goes.

    Regards,

    Jorge

    Thread Starter greenrooster

    (@greenrooster)

    Cool! Thank you @wpmudevsupport15, for this. I will try this out as soon as I am able.

    Thread Starter greenrooster

    (@greenrooster)

    @wpmudevsupport15 This does exactly as I need it to. Thank you! I’m going to close this ticket now.

    Plugin Support Zafer – WPMU DEV Support

    (@wpmudevsupport15)

    Thank you for letting us know @greenrooster

    Feel free to start a new ticket if you need further help.

    Regards,

    Jorge

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Modify {all_fields} output’ is closed to new replies.