• Resolved marianssen

    (@marianssen)


    Hi,

    I’m looping through every Gravity Form I have created using form id and the rgar function. I’m retrieving all the information from the form correctly, but I need to retrieve the PDF form ID as well in order to built a download link.

    Could you please share, how this can be achieved? Below is my code. $pdf_id is the variable in need to get.

    `for( $i=1; $i<=1000; $i++ ){
    $form_id = $i;
    $search_criteria = array();
    $sorting = array();
    $paging = array( ‘offset’ => 0, ‘page_size’ => 25 );
    $total_count = 0;
    $entries = GFAPI::get_entries( $form_id, $search_criteria, $sorting, $paging, $total_count );

    $entry_counter = 0;

    foreach ( $entries as $entry ) :
    $entry_counter++;
    $url = “http://localhost/nitra-2/wp-admin/admin.php?page=gf_entries&view=entry&id=&#8221; . $form_id . “&lid=” . $entry_counter;
    $source_url = rgar( $entry, ‘source_url’ );
    $form_user_id = rgar( $entry, ‘created_by’ );
    $entry_id = rgar( $entry, ‘id’ );
    $pdf_id = rgar( $entry, ‘pid’ );
    ?>
    <?php if( $user_id === $form_user_id ) : ?>
    <p style=”padding: 30px; border: 1px solid #000;”>
    <strong>Formulár č. <?php echo $form_id; ?></strong><br>
    <?php echo rgar( $entry, ‘1’ ) . ‘, ID: ‘ . rgar( $entry, ‘id’ ) . ‘, SOURCE URL:<a href=”‘ . $source_url .'”>’ . $source_url . ‘</a><br>’;?>
    <a href=”<?php echo $url; ?>”>ENTRY URL</a><br>
    ENTRY ID: <?php echo $entry_id; ?><br>
    PID: <?php echo $pdf_id; ?>
    </p>
    <?php endif; ?>
    <?php endforeach;
    }`

    Regards

    • This topic was modified 4 years, 4 months ago by marianssen.
Viewing 1 replies (of 1 total)
  • Plugin Author Jake Jackson

    (@blue-liquid-designs)

    Hey there,

    You can use our API to get an array of all valid PDFs for an entry: https://docs.gravitypdf.com/v6/developers/api/get_entry_pdfs

    Once you have the PDF ID, I recommend displaying the PDF URL by running an appropriately-built [gravitypdf] shortcode through do_shortcode(). For example:

    
    echo do_shortcode( sprintf( '[gravitypdf id="%s" entry="%s" signed="1"]', $pdf_id, $entry_id ) );
    
Viewing 1 replies (of 1 total)

The topic ‘Getting PDF form ID inside gravity form loop’ is closed to new replies.