Hello - I'd like to be able to display all entries from a form on a front-end page. I have reviewed the "Directory" plugin, but it is missing 1 feature that I need: the ability to show only entries with today's date. Is this possible? Thanks!
Hello - I'd like to be able to display all entries from a form on a front-end page. I have reviewed the "Directory" plugin, but it is missing 1 feature that I need: the ability to show only entries with today's date. Is this possible? Thanks!
When you say "all entries", do you mean all fields for every entry? Or do you just want to display first and last name for all entries for today's date for a form? Can you explain more about the data you are capturing with the form and how you would like to display it on the front end?
I wrote a shortcode function a while back for a very specific use like this. It pulls the names from entries for one form. You could extend this to restrict the entries by date. You could also extend this to show more fields than just first name and last name (first initial only in this case):
Thanks! that might be just the ticket.
Let us know if you need help customizing that for your specific application.
Hello,
This is what I need, too. I don't need it as a shortcode, though, just want to use the code directly in my template page. It's not working, though, so I'm wondering if I can get your help.
I grabbed the IDs of the three fields I want to display (for now I'm just going for the organization name, 7). When I try this in my template field, it doesn't work -- and doesn't display anything after it, so I think it's causing problems. Do I need to have something else in place? Do you see anything obvious here that's wrong or missing?
#{Your Organization Name:7}{Organization Contact Name (First):6.3}{Organization Contact Name (Last):6.6}
$form_id = get_the_field("form_id");
$organizations = RGFormsModel::get_leads($form_id, '7', 'ASC');
// loop through all the leads
foreach ($organizations as $member) {
echo $member;
}
Thanks much!
Okay, I figured out my issue. It was in how I was getting the form ID.... :\ "get_the_field" was supposed to be "get_field." I had outputted the ID before with "the_field" and thought I'd done it with this instead.
Anyways. I do have it working now like so:
[php]
<?php
#{Your Organization Name:7}{Organization Contact Name (First):6.3}{Organization Contact Name (Last):6.6}
$form_id = get_field("form_id");
$entries = RGFormsModel::get_leads($form_id, '7', 'ASC');
// loop through all the leads
foreach ($entries as $entry) {
echo "<li>" . $entry[7] . "</li>";
}
?>
</ul>
My remaining question, then, was about how to get more than one field to work. When I tried the 6.3 or 6.6 fields (ex: $entry[6.3] ), nothing was displayed. It made me wonder about this line:
$entries = RGFormsModel::get_leads($form_id, '7', 'ASC');
Does that return the whole record for entries that use the "7" field ID? Or do I have to do something else to get those other fields' data?
Thanks.
That returns all the fields for all entries for form 7. You would have to extract just the entries and fields you need at that point. In your example, you are extracting field 7 for every entry. If you want other fields, just add them in your loop where you have $entry[7]. If you have data stored in the entry in field 24, access that as $entry[24]. You will get the value which is stored in field 24 for every entry which was submitted with form 7.