Programatically show list of a form’s entries via shortcode
-
Hi Guys,
Thanks for the support so far, Adam, Zafer, Kris. you are a legend!
I have another thing going on. As you can see I am using my code to show the latest entry of a form that you guys helped me out to build on another ticketwhat I am trying to achieve now is showing the list of form entries using shortcode. What I did so far is showing just the var_dump but not the actual table of entries. not sure where it went wrong i guess because of the way i populate the array.
here’s the code:add_shortcode('wd-listentries', 'wd_listentries_func');
function wd_listentries_func($atts){
$a = shortcode_atts( array(
'title' => 'guestman',
'field' => 'name-1'
), $atts );
$wd_form_id = get_page_by_title( $a['title'], '', 'forminator_forms' );
$entry = Forminator_Form_Entry_Model::get_entries($wd_form_id->ID);
if ($entry){
var_dump($entry);
foreach ($entry as $item){
echo '<table>';
echo ' <tbody>';
echo ' <tr>';
echo ' <td>';
$entry[] = $item['name-1'];
echo ' </td>';
echo ' <td>';
$entry[] = $item['text-1'];
echo ' </td>';
echo ' <td>';
$entry[] = $item['text-2'];
echo ' </td>';
echo ' </tr>';
echo ' </tbody>';
echo '</table>';
}
}
}the inputs inside the guestman are: name-1, text-1, and text-2.
Is there a specific way to index the individual input inside entries? can you show me where I did wrong? I’m torn between the way i index it or how i foreach it. :/
p/s: again, my programming skill is equivalent of a Psyduck or a salamander, so you guys might want to take me step by stepTHANKS GUYS! YOU ARE THE BEST<3
- You must be logged in to reply to this topic.