Conditional Rendering of E2PDF Shortcodes in Gravity Forms Confirmation Email

22 May, 2025 08:29:59
AirBelV2
Topics: 4
Messages: 16
Hi E2PDF team,

I have a Gravity Forms entry that stores a JSON payload in field (68). This json describes whether the trip is one-way or return, how many passengers, and the details of each flight segment (including “IsReturn” and stop counts).

What I need is to display one PDF download button per passenger per segment in my Gravity Forms confirmation email by using your [e2pdf-download id="…"] shortcode. For example:

One-way, 3 passengers, direct:
[e2pdf-download id="4"] [e2pdf-download id="10"] [e2pdf-download id="11"]

Return, 5 passengers, outbound with stop + inbound direct:
[e2pdf-download id="2"] … [e2pdf-download id="21"] and [e2pdf-download id="5"] … [e2pdf-download id="9"]

Hard-coding the shortcodes in the email editor works fine, but when I generate them dynamically in PHP (using gform_pre_send_email or gform_notification), they never render or get stripped out.

Do you have a recommended approach or example for:

Forcing E2PDF shortcodes to render when injected programmatically into a Gravity Forms notification?

A PHP function or API to get the download links directly (so I can build my own buttons)?

Any pointers or code snippets would be a huge help.

Thanks in advance,
Enzo
22 May, 2025 08:38:01
E2Pdf
Support
Topics: 7
Messages: 3466
Hello,

When E2Pdf shortcodes are called programmatically (via PHP), it is mandatory to set the "dataset" attribute, which corresponds to the Gravity Forms Entry ID (in case the E2Pdf Template is connected to Gravity Form)

echo do_shortcode('[e2pdf-download id="3" dataset="' . $entry_id . '"]');
We would really appreciate your feedback at WordPress.org!
22 May, 2025 08:41:16
E2Pdf
Support
Topics: 7
Messages: 3466
P.S. If you need to build your own buttons, it's possible to output just the URLs by using the "output" attribute: https://e2pdf.com/docs/shortcodes/e2pdf-download#basic

Example:

[e2pdf-download id="1" output="url"] or [e2pdf-download id="1" output="url_raw"]

If called via PHP, the "dataset" attribute is still mandatory.
We would really appreciate your feedback at WordPress.org!
23 May, 2025 06:08:43
AirBelV2
Topics: 4
Messages: 16
That's perfect, thank you very much! I hadn’t added the dataset attribute. Thanks again for your quick response.