Skip Navigation

[Resolved] Form hidden fields

This support ticket is created 4 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

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
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9: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: Africa/Casablanca (GMT+01:00)

This topic contains 19 replies, has 2 voices.

Last updated by leilaG 4 years, 8 months ago.

Assisted by: Jamal.

Author
Posts
#1606105

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

#1608369

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

#1608427

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]

#1608929

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

#1610969

That worked well, Thank you for your support and help finding the solution 🙂