• Resolved dweb2012

    (@dweb2012)


    Hello,

    if( $pdfbutton_action == 'open') {
    
            $mpdf->Output();
    
          } else {
    
            global $post;
            $mpdf->Output( get_the_title( $post->ID ).'.pdf', 'D' );
    	
    		
    		$headers = 'From: Gedimat <[email protected]>' . "\r\n";
            wp_mail ('[email protected]', 'TEST', $post->ID , $header );
          }

    get_the_title( $post->ID ) return the good title
    but when emailed $post->ID is not the current post ID !
    How to get the current post ID ?

    Thank you for your help

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author dinamiko

    (@dinamiko)

    Hi dweb2012,

    try saving initial $post->ID value in a variable and use that variable instead of $post->ID, something like this:

    global $post;
    $post_id = $post->ID;
    $mpdf->Output( get_the_title( $post_id ).'.pdf', 'D' );
    $headers = 'From: Gedimat <[email protected]>' . "\r\n";
    wp_mail ('[email protected]', 'TEST', $post_id , $header );

    Thanks,
    Emili

    • This reply was modified 7 years, 9 months ago by dinamiko.
    Thread Starter dweb2012

    (@dweb2012)

    Hello Dinamiko,
    Thank you for your reply, i used :
    `$pdf = get_query_var( ‘pdf’ );’ as $post_id and it is working.

    As you can see here :

    View post on imgur.com

    I added a link to view and send the PDF as attached document from backoffice, it will be nice, if i can have 2 links : one link to view the PDF and another link to send the PDF via email.

    Thank you

    • This reply was modified 7 years, 9 months ago by dweb2012.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Get current post ID’ is closed to new replies.