• Resolved frafor

    (@frafor)


    Hi there,

    I’m trying to print some special tags in the PDF, such as flamingo’s [_serial_number] to have a progressive ID that matches the e-mail ID.

    However, it doesn’t work.

    It there a way to make it work?

Viewing 1 replies (of 1 total)
  • Thread Starter frafor

    (@frafor)

    It is indeed. Just use _pdf_serial in your pdf template

    /*
    * Makes Flamingo _serial_number work even in PDFs as _pdf_serial
    */
    
    add_filter('wpcf7_posted_data', 'add_serial_number_as_posted_data', 10, 1);
    
    function add_serial_number_as_posted_data($posted_data) {
    
      $wpcf = WPCF7_ContactForm::get_current();
      $submission = WPCF7_Submission::get_instance();
    
      if($submission) {
    
        $post_meta = get_post_meta( $wpcf->id(), '_flamingo', true );
    
      	$channel_id = isset( $post_meta['channel'] )
      		? (int) $post_meta['channel']
      		: wpcf7_flamingo_add_channel(
      				$contact_form->name(), $contact_form->title()
      			);
    
      	if ( $channel_id ) {
      		$serial = 1 + (int) Flamingo_Inbound_Message::count(
      			array( 'channel_id' => $channel_id )
      		);
          // adds some zeroes in front of the serial
          $serial = str_pad($serial, 4, "0", STR_PAD_LEFT);
      	}
    
        if($serial) {
          $posted_data['_pdf_serial'] = $serial;
        }
    
      }
    
      return $posted_data;
    
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Cannot print special tags in PDF’ is closed to new replies.