I am trying to send a notification to the admin about a CRED form filled on the website. I have created a notification in CRED which delivers the details the user fills up in the front end.
I have included %%POST_PARENT_LINK%% to know from which page the form has been filled up. It was working fine sometime back. But, currently I am receiving all the details but %%POST_PARENT_LINK%% is empty. I am unable to track this info.
I haven't made any changes to the form. I had updated the plugins.
As I am working on listings website, it is important to know, on which page the inquiry was posted.
Please resolve. Thank You
Hi, if I understand correctly you would like to get the name of the page from which the CRED form was submitted, correct? Can you try using the following code:
[wpv-post-link id="$current-page"]
Please replace the %%POST_PARENT_LINK%% placeholder with this shortcode to access the name of the page where the CRED form is placed.
Sorry for the late reply.
I tried incorporating your code. I got the following in the notification mail
This e-mail was sent when your contact form on this page was filled
CRED Auto Draft 45679e4a4e3125cf2a265b4488e1a53a
Please help me resolve this.
Thanks and Regards
Hi, I believe this problem is related to a bug that has already been reported to our developers. While they are working on a permanent fix, I can provide a temporary solution for you. Please add the following code to your theme's functions.php file:
// custom cred notification placeholders
add_filter('cred_body_notification_codes', 'custom_generic_field_notification');
add_filter('cred_subject_notification_codes', 'custom_generic_field_notification');
function custom_generic_field_notification( $defaultPlaceHolders ) {
$newPlaceHolders = array(
'%%FORCED_PARENT_TITLE%%' => $_REQUEST['currentpagetitle']
);
return array_merge($defaultPlaceHolders, $newPlaceHolders );
}
Then edit your CRED form and add the following code just before the submit button at the bottom of the form code:
[cred_generic_field field='currentpagetitle' type='hidden' class='' urlparam='']
{
"required":0,
"validate_format":0,
"persist": 1,
"default":"[wpv-post-title]"
}
[/cred_generic_field]
Please try this workaround and let me know if it resolves the parent page title placeholder problem you are experiencing.
Sorry for the late reply.
Here's what I got after I implemented your code.
This e-mail was sent when your contact form on this page was filled
CRED Auto Draft 45679e4a4e3125cf2a265b4488e1a53a
Okay I see. In that case, I would like to take a closer look in your wp-admin area. Please provide login credentials here in the private reply fields. If I need to make adjustments, I will create a clone of your site using the Duplicator plugin:
https://wordpress.org/plugins/duplicator/
Then I can install the site locally and run tests or tweak settings without breaking your live site. If this is okay, please provide the login credentials so I can get started.
Thank you very much for the support. I am sorry for the late reply.
Thank you, may I ask what URL I can visit to fill out the form that triggers your email notification?
hidden link
Please fill the form below the listing.
Thank You
Hi, I've been reviewing your site and I think that you can make these changes to see the parent post title correctly displayed in your email notification:
- Enable the Directory Starter theme
- Edit your email notification to use the '$current-page' operator in the generic field's post title value:
[cred_generic_field field='currentpagetitle' type='hidden' class='' urlparam='']
{
"required":0,
"validate_format":0,
"persist": 1,
"default":"[wpv-post-title id='$current-page']"
}
[/cred_generic_field]
- Add the title placeholder to your email: %%FORCED_PARENT_TITLE%%
This should add the parent post's title to your email notification. Please let me know if I can be of further assistance.
As I do not understand coding well, please help.
Where should I paste %%FORCED_PARENT_TITLE%%? Is it the in the body of the e mail notification?
Also please see that the form below the listing is generating the name of the preschool (at the end). It was supposed to be hidden. Please check the below link.
hidden link
Thank you so much.
Yes, you should paste %%FORCED_PARENT_TITLE%% anywhere you want to include the name of the preschool in the body of your email notification.
It looks like there was a problem copy + pasting the content of your generic form field. Please see the attached screenshot of your CRED form here:
/wp-admin/post.php?post=27&action=edit
The single quotes were replaced with ASCII codes. I'm not exactly sure how that would have happened, but it's an easy fix. I've changed those in your CRED form to use proper single quotes, and this field is now hidden. Please let me know if I can help with anything else here.
I am almost there. Thank you for your patience. I am currently getting the name of the preschool. But, I am unable to get the link to the listing. Please check the snapshots to see what I have done and the result in my inbox.
Okay, for some reason I thought you only needed the title. We can make a modification in functions.php to add to your new placeholders array:
function custom_generic_field_notification( $defaultPlaceHolders ) {
$newPlaceHolders = array(
'%%FORCED_PARENT_TITLE%%' => $_REQUEST['currentpagetitle'],
'%%FORCED_PARENT_URL%%' => $_REQUEST['currentpageurl']
);
return array_merge($defaultPlaceHolders, $newPlaceHolders );
}
In your CRED form, add another generic field:
[cred_generic_field field='currentpageurl' type='hidden' class='' urlparam='']
{
"required":0,
"validate_format":0,
"persist": 1,
"default":"[wpv-post-url id='$current-page']"
}
[/cred_generic_field]
Then in your email notification, add a link like this:
<a href="%%FORCED_PARENT_URL%%">%%FORCED_PARENT_TITLE%%</a>
Let me know how it goes, thanks!
Thanks a lot for your support. I have achieved what I needed. I am sure this will be much easier to do in later versions of CRED as requiring to show the page from where the form has been filled is a common requirement. I appreciate your support towards a non-coder. Thank you very much.