Hi @kemalkautsar
I hope you’re well today!
Forminator does not have any shortcodes to show submitted data on front-end so it would require a bit of additional custom code.
If I correctly understand, this is what you want: show value of the text-2 field from the newest submission of the form, right?
This code should help:
<?php
add_shortcode( 'forminator-last-entry-field', 'wpmu_shortcode_forminator_last_entry_field' );
function wpmu_shortcode_forminator_last_entry_field( $atts ) {
$a = shortcode_atts( array(
'form_id' => 123,
'field' => 'text-2',
), $atts );
$entry = Forminator_Form_Entry_Model::get_latest_entry_by_form_id( $a['form_id'] );
if ($entry) {
$html = $entry->meta_data[$a['field']]['value'];
if ($html) {
return $html;
}
}
}
First, you’d need to add the code to the site as MU plugin:
– create an empty file with a .php extension (e.g. “forminator-last-entry-field-shortcode.php”) in the ‘/wp-content/mu-plugins” folder of your site’s WordPress install
– copy and paste code into it
– optionally, you can set default form ID and field name in this lines
'form_id' => 123,
'field' => 'text-2',
– save the file.
Then you just need to use this shortcode anywhere on site:
[forminator-last-entry-field]
If you add it like this – without any parameters – it will use default configuration (form ID and field name) set in the code.
But you can as well use it like this
[forminator-last-entry-field form_id=”123″, field=”text-1″]
where 123 would be an ID of a form of your choice and the field would indicate field that you want to display value of.
It will always fetch value of that field for that form from the newest submission.
Best regards,
Adam