Write UID into a field on Post Create

4 July, 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? =)
4 July, 2024 02:56:37
E2Pdf
Support
Topics: 7
Messages: 3345
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!
5 July, 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 !