Variables in arg

WordPress
October 21, 2021 13:05:30
jimp
Topics: 2
Messages: 5
I am trying to display a variable inside the PDF template ($PRODNUM). I have tried [e2pdf-view id="2" arg1="'.$PRODNUM.'"] with [e2pdf-arg key="arg1"] inside the template, but it only returns the string '.$PRODNUM.' . I have echoed the variable on the page outside the template, so I know there is data in the variable.
October 21, 2021 23:17:19
E2Pdf
Topics: 7
Messages: 3617
Support
Hi,

If you are trying to put this shortcode inside WordPress Page Content - unfortunately it will not work as PHP variables not available in this context.

You have 2 possible solutions:

1. Output the shortcode via PHP via custom hook / action / editing wordpress page template as:

echo do_shortcode('[e2pdf-view id="2" dataset="' . $dataset . '" arg1="' . $PRODNUM . '"]');

* where $dataset must be the Page ID

OR

2. If $PRODNUM can be retrieved by Page ID, you can use shortcode inside E2Pdf Template as:

[e2pdf-wp key="prodnum" meta="true"]

and PHP filter which must be added to your functions.php / PHP snippet, where you will add code which will get $PRODNUM by Page ID (if it's not $_POST / $_GET post data) :

https://codeshare.io/VZj0Q3

We remain at your service.

We would really appreciate your feedback at WordPress.org!
October 22, 2021 11:20:53
jimp
Topics: 2
Messages: 5
Thank you so much for your response. Yes, $PRODNUM is retrieved through $_GET. And I simply inserted

$dataset = get_queried_object_id();

in my page template above your

echo do_shortcode('[e2pdf-view id="2" dataset="' . $dataset . '" arg1="' . $PRODNUM . '"]');

to get the Page ID, and it worked perfectly.

Thank you again! I have another question (pre-sale), but will post it in that section.
Get News and Updates
Our monthly newsletter keeps you in the loop, so you'll always be up to date with the latest news and updates about E2Pdf.
* You can update your email subscription preferences here.
All trademarks, service marks, trade names, product names, and logos appearing on this website are the property of their respective owners. The use of trademarks such as Formidable Forms®, Forminator Forms®, Gravity Forms®, JetFormBuilder®, WordPress®, WooCommerce®, WPForms® and others is solely for identification purposes (nominative use) and does not imply any affiliation, sponsorship, or endorsement by the respective trademark holders.
© 2017 - 2026, https://e2pdf.com

We use cookies to collect and analyse information on site performance and usage, to provide social media features and to enhance and customise content and advertisements. By clicking "Accept Selected", you consent to use of selected cookies according to our Cookie Policy.