PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Display Today's Form Entries on Front-end Pages

  1. 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!

    Posted 13 years ago on Friday October 19, 2012 | Permalink
  2. 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):

    http://pastebin.com/FUF9HA6B

    Posted 13 years ago on Wednesday October 24, 2012 | Permalink
  3. Thanks! that might be just the ticket.

    Posted 13 years ago on Monday October 29, 2012 | Permalink
  4. Let us know if you need help customizing that for your specific application.

    Posted 13 years ago on Monday October 29, 2012 | Permalink
  5. relish1227
    Member

    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!

    Posted 13 years ago on Friday November 2, 2012 | Permalink
  6. relish1227
    Member

    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.

    Posted 13 years ago on Wednesday November 7, 2012 | Permalink
  7. 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.

    Posted 13 years ago on Thursday November 8, 2012 | Permalink