Save button in backend post edit page

WordPress
20 April, 2021 08:19:38
eliodata
Topics: 16
Messages: 49
Hi there,
Last time you helped we create a metabox displaying my template into the admin post editor:

https://e2pdf.com/support/desk/download-button-in-backend-post-edit-page

Thank you again for the great support!
Is it possible to add a save button shortcode under the pdf view shortcode please? We would like to store some results on the server.

Best regards
20 April, 2021 13:33:24
E2Pdf
Support
Topics: 7
Messages: 3345
Hi,

Here is simplified modified previous code solution: https://codeshare.io/aYpWwY.

In general it must be added custom ajax function which must be called via javascript, which will call [e2pdf-save] shortcode.

Note please: Current code must work however to be correctly: JS code must be added to .js file which must be included via WordPress hooks + it's recommended to add "nonce" security check. Unfortunately to build it correctly we can offer you only paid support.

The file will be saved to default folder if "dir" attribute will not be set with "post_id" name according documentation: [e2pdf-save]

We remain at your service.
We would really appreciate your feedback at WordPress.org!
20 April, 2021 14:42:57
eliodata
Topics: 16
Messages: 49
Your code works great, thank you.
One thing, when I download the pdf the name is ok (I use shortcodes in template name). But when I save the pdf the name is the post ID.
Any idea please?
20 April, 2021 15:04:15
E2Pdf
Support
Topics: 7
Messages: 3345
Modify:

do_shortcode('[e2pdf-save id="1" dataset="' . $dataset . '" name="' . $dataset . '" apply="true"]');

To:

do_shortcode('[e2pdf-save id="1" dataset="' . $dataset . '" apply="true"]');

It must use PDF Name from E2Pdf Template if no name set. Keep in mind that by default PDF will be overwritten if same name.

We remain at your service.
We would really appreciate your feedback at WordPress.org!
20 April, 2021 16:55:45
eliodata
Topics: 16
Messages: 49
Damned, perfect :)
May I ask you it is possible to generate folder name dynamically, like post title, post ID or any custom field ?
Many thanks again and again...
20 April, 2021 17:40:48
E2Pdf
Support
Topics: 7
Messages: 3345
E2Pdf can create dynamic dirs, it must be used "dir" with "create_dir" attribute.

https://e2pdf.com/support/docs#shortcode-e2pdf-save

as follows:

do_shortcode('[e2pdf-save id="1" dataset="' . $dataset . '" dir="wp-content/uploads/dir/" create_dir="true" apply="true"]');

You must be able still use shortcodes inside "dir" attribute or create it dynamic via PHP with needed values as:

$post = get_post($dataset);
if ($post) {
$dir = 'wp-content/uploads/dir/' . $post->ID;
do_shortcode('[e2pdf-save id="1" dataset="' . $dataset . '" dir="'.$dir.'" create_dir="true" apply="true"]');
}

We remain at your service.
We would really appreciate your feedback at WordPress.org!
20 April, 2021 20:34:38
eliodata
Topics: 16
Messages: 49
Works like a charm, as usual.

Thank you for your help!