Gravity PDF multiple entries in one PDF (based on criteria)

Hi all

I use Gravity PDF and create custom templates for a lot of our responses. I am now looking at creating an attendee list based on what option a user has entered as a workshop in Gravity Forms.

I was wondering if this is indeed possible as it would need to pull data in from more than one response?

If it is possible, is there also a way to do this dynamically (so I only have to have one PDF) rather than creating a PDF for each type of workshop (as we may reuse this form for other bookings with new workshops in the future)

Hi all,

Just in case anyone was looking to do something similar in the future I thought I’d share a solution.

The below creates an attendee list dependant on the workshop selected in any response which I use to generate a PDF. This means I only need to select one attendee for a course, e.g. Health and Safety, and it will generate a list for every person which is due to attend.

$fullname = array();
$condition1 = $form_data['field'][##]; /** name of course */
$condition2 = $form_data['field'][##]; /** date of course */

$search_criteria = array();
$sorting = array();
$total_count = 0;
$paging = array( 'offset' => 0, 'page_size' => $total_count );
$entries = GFAPI::get_entries( $form_id, $search_criteria, $sorting, $paging, $total_count );

foreach ($entries as $entry) {

    $conditional1 = rgar($entry, 'field id'); /** name of course in each response */ 
    $conditional2 = rgar($entry, 'field id'); /** date of course in each response */

/** replace field id with the input value which needs to match the criteria */

    if ( $conditional1 == $condition1 ) && ($conditional2 == $condition2) {

/** This will determine whether the name and dates of the course match */

    $fullname[] = rgar($entry, 'Field Id') . ' ' . rgar($entry, 'Field Id');

/** replace field id's with first and last name to make a list of attendees  */

    }

}

After the CSS section I got the data meeting the criteria from all of the responses to show on new lines through the following code:

<?php echo implode('< br />', $fullname); ?>

2 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.