• Resolved pederweb

    (@pederweb)


    Hi there,

    I have added some custom code to my functions.php file to enable special formatting to be applied to some of the data that is being entered into my forms. For example, when someone enters a phone number with no spaces (ex: 3335551212), my code will add dashes to the number so that, when I receive the phone number in the email, it will look like this…

    333-555-1212

    However, when I open the PDF that is attached to the email using this plugin, there are no dashes in the phone number. That coding that I have installed only effects the output going to the email, not the pdf.

    I am wondering if there is a way to add code that will effect the data that is being entered into the pdfs.

    The creator of the CF7 plugin has created a guide for creating mail tag replacements at https://contactform7.com/2019/12/08/customizing-mail-tag-replacement/

    Is there some kind of guide similar to this for creating pdf tag replacements?

    Thanks!

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author ZealousWeb

    (@zealopensource)

    Hello pederweb,

    Certainly, you need to add implemented custom code in the file class.cf7-pdf-generation.front.filter.php.

    File path : wp-content/plugins/generate-pdf-using-contact-form-7/inc/front/

    if (is_numeric($value)) {
    $formattedValue = number_format($value);
    $msg_body = str_replace($value,$formattedValue,$msg_body);
    }

    You should include this code at line number 275, and you’ve provided supporting evidence in the form of a screenshot, accessible through this link https://prnt.sc/YzMZRIfbFb_3

    The link you’ve shared, such as https://contactform7.com/2019/12/08/customizing-mail-tag-replacement/, demonstrates a code example that transforms the output from “11111111111111” to “11,111,111,111,111.”


    Thank you,
    ZealousWeb

    • This reply was modified 1 year, 7 months ago by ZealousWeb.
    • This reply was modified 1 year, 7 months ago by ZealousWeb.
    • This reply was modified 1 year, 7 months ago by ZealousWeb.
    Plugin Author ZealousWeb

    (@zealopensource)

    Hello pederweb,

    It appears that you want to achieve the following output: “3335551212” to “333-555-1212”.

    you need to add implemented custom code in the file class.cf7-pdf-generation.front.filter.php

    if (strlen($value) === 10 && is_numeric($value)) {
    $formattedValue = substr($value, 0, 3) . ‘-‘ . substr($value, 3, 3) . ‘-‘ . substr($value, 6, 4);
    $msg_body = str_replace($value,$formattedValue,$msg_body);
    }

    You should include this code at line number 275, and you’ve provided supporting evidence in the form of a screenshot, accessible through this link https://prnt.sc/L6csCMpF2XmD

    If you have any questions, please don’t hesitate to ask.

    Thank you,
    ZealousWeb

    Thread Starter pederweb

    (@pederweb)

    Thanks so much for your quick response!

    I have attempted what you suggested above, but ran into a couple of problems. First, the file that you suggested, the ../front.filter.php file only had 59 lines of code in it. See screenshot here: https://prnt.sc/W69Q1LZeKt5o

    I did try to plug the code into that file in various places, but just got errors on the front end.

    I then took a look at the ../front.action.php file, and I found the same code as what you have in the screenshot in that file, close to line 275, at line 273. So, I inserted the code where you suggested in that file. See screenshot here: https://prnt.sc/Mye157Mc5LIa

    When I refreshed my page with the form I got this error message:

    Deprecated: The behavior of unparenthesized expressions containing both ‘.’ and ‘+’/’-‘ will change in PHP 8: ‘+’/’-‘ will take a higher precedence in?../wp-content/plugins/generate-pdf-using-contact-form-7/inc/front/class.cf7-pdf-generation.front.action.php?on line?274

    What would you suggest I do here? Thanks again!

    Plugin Author ZealousWeb

    (@zealopensource)

    Hello pederweb,

    Kindly evaluate the video link I’ve provided in the attachment video link and implement the required adjustments to align with the desired style.

    Video link : https://tinyurl.com/25lsebsf

    After reviewing the changes made to my video, are you content with the outcome?

    Thank you,
    ZealousWeb

    • This reply was modified 1 year, 7 months ago by ZealousWeb.
    Plugin Author ZealousWeb

    (@zealopensource)

    Hello pederweb,

    Insert the provided code below and paste it after line 273 in the “class.cf7-pdf-generation.front.action.php” file, then verify its functionality.
    See screenshot here. https://prnt.sc/1Fx1VJhviW-D

    if (strlen($value) === 10 && is_numeric($value)) {
    	$formattedValue = substr($value, 0, 3) . '-' . substr($value, 3, 3) . '-' . substr($value, 6, 4);
    	$msg_body = str_replace($value,$formattedValue,$msg_body);
    }

    If you have any questions or need further assistance, please don’t hesitate to ask. I’m here to help

    Thank you,
    zealousweb

    • This reply was modified 1 year, 7 months ago by ZealousWeb.
    Thread Starter pederweb

    (@pederweb)

    Yes! Thank you so much! This is now working exactly how I want it to! I really appreciate your help on this, and my client will be VERY pleased!

    Plugin Author ZealousWeb

    (@zealopensource)

    Hello pederweb,

    Thank you very much for your kind words. We would greatly appreciate it if you could kindly share your feedback with us.
    https://www.ads-software.com/support/plugin/generate-pdf-using-contact-form-7/reviews/#new-post

    Thank you,
    zealousweb

    • This reply was modified 1 year, 7 months ago by ZealousWeb.
    • This reply was modified 1 year, 7 months ago by ZealousWeb.
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Customized mail tags in CF7 are not being transferred to PDF’ is closed to new replies.