Write UID into a field on Post Create

July 04, 2024 02:47:04
lukashwm
Topics: 2
Messages: 10
I'd like to create and save the uid of a created post in a custom post field at the moment the post is created.

The background is that I want to return the pdf download link via api when the post is created via the API.

My actual approach is to make a get request on the created post and than get the uid from the database but it's not the best workaround.

Any suggestions? =)
July 04, 2024 02:56:37
E2Pdf
Topics: 7
Messages: 3617
Support
Hello,

If you need the PDF download URL, you should be able to manually trigger the shortcode via PHP, for example:

Encoded URL:
$url = do_shortcode('[e2pdf-download id="1" dataset="'. $post_id .'" output="url"]');

Unencoded URL:
$url = do_shortcode('[e2pdf-download id="1" dataset="'. $post_id .'" output="url_raw"]');

URL with wrapper, a href="...":
$url = do_shortcode('[e2pdf-download id="1" dataset="'. $post_id .'"]');

* where $post_id is the Post ID for which it should be generated PDF.

P.S. The PDF UID is created only when the PDF generation is triggered.

We would really appreciate your feedback at WordPress.org!
July 05, 2024 05:19:54
lukashwm
Topics: 2
Messages: 10
Works perfectly. Thank you very much, I wasn't aware of the do_schortcode() function =) Awesome !
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.