Skip Navigation

[Resolved] Use custom form field in notification

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 1 reply, has 2 voices.

Last updated by Minesh 1 year, 4 months ago.

Assisted by: Minesh.

Author
Posts
#2623713

I need to use a custom form field value in the notification email. This field is called comercial.

<label for="%%FORM_ID%%_comercial">[cred_i18n name='comercial-label']Accepto enviament de correus comunicació[/cred_i18n]</label>
[cred_generic_field type='checkbox' field='comercial']
{
"required":0,
"default":"0"
}
[/cred_generic_field]

I found a solution in docs, and created this code in functions.php

add_filter('cred_subject_notification_codes', 'custom_generic_field_notification', 10, 1);

add_filter('cred_body_notification_codes', 'custom_generic_field_notification', 10, 1);

function custom_generic_field_notification( $defaultPlaceHolders ) {

$newPlaceHolders = array(
'%%COMERCIAL%%' => $_REQUEST['comercial']
);

return array_merge($defaultPlaceHolders, $newPlaceHolders );
}

And then in notification email %%COMERCIAL%%

I check the field in form, and I get a 0, not a 1.

Thank you,

#2623717

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please try to replace your generic field shortcode as given under and then test and try to resolve your issue.

[cred_generic_field type='checkbox' field='comercial']
{
"required":0,
"default":"1"
}
[/cred_generic_field]