Tell us what you are trying to do?
I've created a dynamic contact form that allows users to contact the post owner (housing add directory)
The contact form used to send an email to me AND the post owner.
It worked perfeclty for 2 weeks, then stopped to include the post owner's email
I did modifications in the housing template, but it shouldn't affect the contact form.
Here is the original support tread: https://toolset.com/forums/topic/how-to-add-a-dynamic-contact-form-in-a-custom-post-type-template/
Thanks 😀
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Hello. Thank you for contacting the Toolset support.
With your form:
- hidden link
I've adjusted the owner email field from:
[cred_generic_field field='owner-email' type='email' class='' urlparam='']
{
"required":0,
"validate_format":0,
"persist":1,
"default":"[wpv-post-field name='wpcf-courriel' id='$current_page']"
}
[/cred_generic_field]
To:
[cred_generic_field field='owner-email' type='email' class='' urlparam='']
{
"required":0,
"validate_format":0,
"persist":1,
"default":"[types field='courriel' output='raw'][/types]"
}
[/cred_generic_field]
Can you please confirm it works as expected.
Good morning Minesh,
Yes it works, thanks!
I've added extra code to show the post title and post URL, so it's easier for the receiver to know from with add / post the message was sent.
I copied your code, changed the fields info, but it doesn't work.
As you'll see, I tried with [type] or [wpv-post-field]. I also tried with and without the 'wp' slut (wp-post-title)
[cred_generic_field field='titre-fiche' type='textfield' class='' urlparam='']
{
"required":0,
"validate_format":0,
"persist":1,
"default":"[types field='post-title' output='raw'][/types]"
}
[/cred_generic_field]
[cred_generic_field field='url-fiche' type='url' class='' urlparam='']
{
"required":0,
"validate_format":0,
"persist":1,
"default":"[wpv-post-field name='wp-post-url' id='$current_page']"
}
[/cred_generic_field]
[/cred_generic_field]
I've also added the fields in the email notification
[wpml-string context="template-logement"]Fiche : [/wpml-string][types field='form-titre-fiche'][/types]
[wpml-string context="template-logement"]URL : [/wpml-string][types field='form-url-fiche'][/types]
What dit I do wrong? hahah
Catherine 🙂
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
What if you try to add generic hidden field to hold the title and URL:
For example - add the following fields to your form and save your form:
[cred_generic_field field='parent-post-title' type='hidden' class='' urlparam='']
{
"required":0,
"validate_format":0,
"default":"[wpv-post-title]"
}
[/cred_generic_field]
[cred_generic_field field='parent-post-url' type='hidden' class='' urlparam='']
{
"required":0,
"validate_format":0,
"default":"[wpv-post-url]"
}
[/cred_generic_field]
Then use the "Custom Code" section offered by Toolset to add the following hook (make sure to activate the code snippet):
=> https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/
add_filter('cred_subject_notification_codes', 'func_add_parent_post_title_to_email_notification', 10, 1);
add_filter('cred_body_notification_codes', 'func_add_parent_post_title_to_email_notification', 10, 1);
function func_add_parent_post_title_to_email_notification( $defaultPlaceHolders ) {
if( !isset( $_REQUEST['parent-post-title'] ) ) {
return $defaultPlaceHolders;
}
$newPlaceHolders = array(
'%%PARENT_POST_TITLE%%' => $_REQUEST['parent-post-title'],
'%%PARENT_POST_URL%%' => $_REQUEST['parent-post-url'],
);
return array_merge($defaultPlaceHolders, $newPlaceHolders );
}
After that you should add the custom placeholder to your email as:
[wpml-string context="template-logement"]Fiche : [/wpml-string] '%%PARENT_POST_TITLE%%
[wpml-string context="template-logement"]URL : [/wpml-string] %%PARENT_POST_URL%%
More info:
- https://toolset.com/documentation/programmer-reference/forms/how-to-use-custom-placeholders-in-cred-notifications/
Good morning Minesh,
Sorry for late reply, I got a busy week.
I did all the changes, and this is what I got in the notification
Message :
test
Fiche : ‘%%PARENT_POST_TITLE%%’
URL : ‘%%PARENT_POST_URL%%’
I tried with and without the ' sign
Catherine 🙂
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Can you please share problem URL where you added your form as well as admin access details and let me review your current setup and check whats going wrong.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
When I checked the "Custom Code" section with the code snippet "contact-fiche-url-titre" you added:
- hidden link
I found that the code snippet you added was inactive. I've activated that code snippet. Can you please confirm and check its working now.
Eh boy.. hahahah
My bad!
Now everything works fine !
Thanks 😀