Thanks for the code.
Yes we have already attached the taxonomies to the "Space enquiry form" custom post type - hidden link
The taxonomies term labels are now showing in the email notification hidden link
But the selected terms are not passing through to the form.
We removed display none to check how they are displayed in the form - hidden link
I tried locally to pass a value to the taxonomy with the form but there is no way. We need to use custom development.
The custom code will either use the values passed in the form on a generic field. Or it can pull the information from the database if we page the post_id of the "parent" post.
Check the following article, it shows how to create custom placeholder '%%PRODUCT_NAME%% to the notification email. You can create your own %%LOCATION%% AND %%BUILDING%%
https://toolset.com/documentation/user-guides/front-end-forms/how-to-use-custom-placeholders-in-cred-notifications/
The code has to be added to your theme functions.php file or in Toolset->Settings->Custom code
Okay so we added the code for Location and Building to functions.php to a function that was already there for a different form.
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(
'%%NAME%%' => $_REQUEST['Name'],
'%%EMAIL%%' => $_REQUEST['Email'],
'%%COMPANY_NAME%%' => $_REQUEST['company_name'],
'%%LOCATION%%' => $_REQUEST['Location'],
'%%BUILDING%%' => $_REQUEST['Building']
);
return array_merge($defaultPlaceHolders, $newPlaceHolders );
}
Not sure what to put in the generic field to pull the taxonomy through to the notification?
[cred_generic_field type='' field='building' type='hidden' class='' urlparam='']
{
"required":1,
"validate_format":0,
"default":"",
"persist":1
}
[/cred_generic_field]
You pass the value to the "default" key with the wpv-post-taxonomy shortcode like this:
[cred_generic_field type='' field='building' type='hidden' class='' urlparam='']
{
"required":1,
"validate_format":0,
"default":"[wpv-post-taxonomy type='location' format='name' item='$current_page']",
"persist":1
}
[/cred_generic_field]
Note that I used the format='name' to get the name of the building. Read more about the shortcode here https://toolset.com/documentation/user-guides/views/views-shortcodes/#vf-153472
That worked well, Thank you for your support and help finding the solution 🙂