• Hi

    Very nice plugin it works fine to me. But i want to add a downloadable link for pdf doc in users mail. If i add just with hypertext tag in user email settings it will open my pdf file link in new tab. But i dont want to open my pdf doc in new tab if the user click on the link that should download within their mail window. How to do this please help.

    Regards
    Karthik

    http://wordpress.org/plugins/ninja-forms/

Viewing 6 replies - 1 through 6 (of 6 total)
  • 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.

    Thread Starter Jayakarthik

    (@jayakarthik)

    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”);

    Thread Starter Jayakarthik

    (@jayakarthik)

    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.

    Plugin Author James Laws

    (@jameslaws)

    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.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Add direct download link in user mail settings.’ is closed to new replies.