You can use PHP script for you to auto download the pdf file.
Link:
$pdf_link = add_query_arg(
array(
"action" => "pdf_download",
"file" => $fname . ".pdf",
"_wpnonce" => wp_create_nonce("security-code-for-your-file-download")
), admin_url("admin-post.php"));
<a href="$pdf_link">Download PDF</a>
Function:
public static function pdf_download(){
$fullPath = WP_PLUGIN_DIR."/".$_GET['file'];
$fsize = filesize($fullPath);
$path_parts = pathinfo($fullPath);
// We'll be outputting a PDF
header('Content-type: application/pdf');
// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="'.$path_parts["basename"].'"');
header("Content-length: $fsize");
header("Cache-control: private"); //use this to open files directly
readfile($fullPath);
exit;
}
Hope it helps.
Hi
Can you please explain little bit more how to add this code to get work.
1. Do i need to add the “Link” code in ninja forms User Email Settings block. There is a text editor only right then how could i add the php code in that?
2. I have added the “Function” code in my themes function.php file while i am trying to save that file it shows blank page after that my overall site will not opens it shows only blank page, so i removed now it opens fine.
So please help me some more details are examples.
Regards
Karthik
How did you create your pdf and anchor link for email?
Can I see your code? where you setup the link for email?
My Code above ex.:
link code – is use for creating link url for the anchor tag
function code – is the function that will receive the link for download
Also I forget to add this. Sorry.
//hooks up download action
add_action(“admin_post_pdf_download”, “pdf_download”);
Hi
I just upload my pdf into wp-content/uploads folder and give the link with hypertext tag in ninja forms user email settings text editor block. The following link i have added in users mail settings block <a href="https://mydomain.com/sitefolder/wp-content/uploads/Brochure/1g h5dv 3d/eLearning Solutions.pdf"><img alt="Download Brochure" src="https://mydomain.com/sitefolder/wp-content/uploads/2013/12/Download-Brochure.png" /></a>
So do i need to add the both link code and function code in my themes/functions.php file.
ah okay, I was thinking that you did automatically create you pdf using php and email directly to recipient.
The easiest way to do that is to install download manager plugin Link then copy the embed code of the specific file you want to be downloaded.
That’s it hope I did solved your problem.
As we’ve stated in this sticky thread, we don’t offer support on these forums but of you would like support from the developers you can follow the support link it provides and we’d be happy to assist you.
If you are happy waiting here to see if someone else can assist you, you are welcome to do that as well.