Forked from techjewel/new_form_submission_smartcode.php
Created
July 20, 2021 11:09
-
-
Save nkb-bd/b23dfd1ca54be75526c3c8d39d9e6414 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter('fluentform_form_settings_smartcodes', function ($groups) { | |
$groups[0]['shortcodes']['{adrian_all_data}'] = 'Custom All Data'; | |
return $groups; | |
}); | |
add_filter('fluentform_shortcode_parser_callback_adrian_all_data', function ($return, $instance) { | |
$form = $instance::getForm(); | |
$entry = $instance::getEntry(); | |
$formFields = \FluentForm\App\Modules\Form\FormFieldsParser::getEntryInputs($form); | |
$inputLabels = \FluentForm\App\Modules\Form\FormFieldsParser::getAdminLabels($form, $formFields); | |
$response = \FluentForm\App\Modules\Form\FormDataParser::parseFormSubmission($entry, $form, $formFields, true); | |
$html = '<table class="ff_all_data" width="600" cellpadding="0" cellspacing="0"><tbody>'; | |
foreach ($inputLabels as $key => $label) { | |
if (!empty($response->user_inputs[$key])) { | |
$data = $response->user_inputs[$key]; | |
if (is_array($data) || is_object($data)) { | |
continue; | |
} | |
$html .= '<tr class="field-label"><th style="padding: 6px 12px; background-color: #f8f8f8; text-align: left;"><strong>' . $label . '</strong></th></tr><tr class="field-value"><td style="padding: 6px 12px 12px 12px;">' . $data . '</td></tr>'; | |
} | |
} | |
// you can add your own <tr> <td> | |
$html .= '</tbody></table>'; | |
return $html; | |
}, 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment