Customizing e-mails
-
Hi, I understand I can customize an email by adding specific field names, but I was wondering if I could customize the output of checkbox fields? Instead of listing each checked option inline, I’d like them to be on seperate lines. Is that possible? I am guessing it might require editing the plugin code..
-
Hi,
Yes, you are in the right direction, in this case is needed customize the plugin’s code.
Please, follows the steps below:
1. Open the “/wp-content/plugins/calculated-fields-form/cp_calculatedfieldsf.php” file with the text editor your choice.
2. Go to the snippet of code:
$value = ( !empty( $value ) || is_numeric( $value ) && $value == 0 ) ? ( ( is_array( $value ) ) ? implode( ", ", $value ) : $value ) : '';
and modify it as follows:
$value = ( !empty( $value ) || is_numeric( $value ) && $value == 0 ) ? ( ( is_array( $value ) ) ? implode( "<br>", $value ) : $value ) : '';
3. Finally, insert the field in the email, and select the “HTML” option as the format of the email, in form’s settings.
and that’s all.
Best regards.I’ve done as you recommend, but it does not seem to have had the desired effect.. I don’t have a caching plugin installed, and I’m uncertain why it’s not working..
Hi,
I will need to check the form’s settings, and the modified code. Please, create a ticket in my private support page with the access to your WordPress:
http://wordpress.dwbooster.com/support
Best regards.
I still get a bounce message in my email when I use your website’s ticket form.
The line I edited is 1332, and this is what I changed it to:
$value = ( !empty( $value ) || is_numeric( $value ) && $value == 0 ) ? ( ( is_array( $value ) ) ? implode( "<br>", $value ) : $value ) : '';
Hi,
Please, remember, that in this case, where has been modified the plugin’s code, you should replace the special tag ‘<%INFO%>’ in the notification emails, by the tags of the fields directly.
If the issue persists, please, create a ticket in my private support page with the access to your WordPress:
http://wordpress.dwbooster.com/support
Best regards.
I see, is there a way to make the changes work for
<%INFO%>
? Actually what I’d like to do is make the change work for the ‘summary’ field in the form, I am guessing Summary uses the same function as<%INFO%>
..?I realized the summary field does what I wanted in another post, but it still displays checkbox fields as Value, Value, Value, when what I want is:
Value
Value
ValueSo I can copy and paste to e-mails. I would like to have each value on it’s own line in both summaries, and emails sent at submission.
Hi,
In this case you will need to replace the snippet of code:
$buffer .= $fields[str_replace($_POST["cp_calculatedfieldsf_pform_psequence"],'',$item)]->title . ": ". (is_array($value)?(implode(", ",$value)):($value)) . "\n\n";
with
$buffer .= $fields[str_replace($_POST["cp_calculatedfieldsf_pform_psequence"],'',$item)]->title . ": ". (is_array($value)?(implode("\n",$value)):($value)) . "\n\n";
Best regards.
That worked for emails, but it looks as tho summaries are handled elsewhere, can I change that also?
Also, if you could tell me how to add a
<br>
or\n
to the end of the field label when using<%fieldname# if_not_empty%>
that would be excellent 🙂Hi,
It is really hard customize the plugin’s code remotely, without access to it.
Ok, in addition to the previous modifications, go to the snippet of code:
if( is_array( $result->paypal_post[ $field ] ) ) $result->paypal_post[ $field ] = implode( ',', $result->paypal_post[ $field ] );
and replace it with the following one:
if( is_array( $result->paypal_post[ $field ] ) ) $result->paypal_post[ $field ] = implode( '<br>', $result->paypal_post[ $field ] );
Best regards.
Okay, so with the changes on Line 479 and line 997 it is formating <%INFO> properly the way I wanted..
That is probably the best.. I’d like to be able to precisely format the letter using <%fieldname#%>, but I dont know if that’s possible.. If I change line 1332 it adds a
after each item in the value array, but not the last item (because it doesn’t have a separator?), so the label for the next field is right next to it.. If I add a
into the letter manually, then when a field isn’t shown because it’s empty it ends up displaying extra blank lines in the email.Hi,
Please, pay attention to the plugin’s documentation:
http://wordpress.dwbooster.com/faq/calculated-fields-form#q81
The tag can be inserted with the following attributes:
<%fieldname3 if_not_empty after={{<br>}}%>
In whose case the field with name: fieldname3 will be inserted in the email or thank you page only if it is not empty, and if it is inserted, the plugin will insert at the end, the tag
<br>
, that correspond to a change of line.Best regards.
Awesome! Thank you! 🙂 I read through the docs twice! but somehow I overlooked that.. I was probably lacking sleep 😉
- The topic ‘Customizing e-mails’ is closed to new replies.