Hi!
Are you using the {all_fields} tag to include the fields in your email? If so, all fields will be included. Unfortunately there currently isn’t a simple way to exclude fields while using this tag but it might be added in a future version (I’ve put in on my list). One solution could be to manually include each field with a tag instead of using {all_fields} although I understand that would be cumbersome. Another solution if you don’t mind writing some code is to build you own email with the af/form/email/content filter. You could then use the _af_render_field_include($field, $value=false) (api/api-helpers.php) helper function to include a single field.
Hope this helps!
Beautiful.
I’m not entirely clear on the usage of the helper function, particularly the $value = false.
So… if I wanted to conditionally include a field, it would be something like this(?):
function mail_content( $content, $email, $form, $fields ) {
$content = ''; // to clear the default content
$show_company = af_get_field( 'show_company' ); // a True/False field
$company = af_get_field( 'company' );
if ( $show_company && $company !== '' ) {
$content .= "Company: " . _af_render_field_include( 'company', $value = true);
}
}
Or use the $fields variable perhaps this?:
function mail_content( $content, $email, $form, $fields ) {
$content = ''; // to clear the default content
$show_company = $fields['show_company']; // a True/False field
$company = $fields['company'];
if ( $show_company && $company !== '' ) {
$content .= "Company: " . _af_render_field_include( 'company', $value = true);
}
}
(I’m never sure when to use $var[‘val’] vs $var->val)
I think this is what I need for a current problem with only sending certain headers conditionally based on a sub-field. But I can’t get it to work.
Wondering if your code worked above @cvc1968?