Skip Navigation

[Resolved] CRED form custom placeholders no longer working on live site

This support ticket is created 3 years, 2 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: Asia/Karachi (GMT+05:00)

This topic contains 8 replies, has 2 voices.

Last updated by nicoleR-3 3 years, 2 months ago.

Assisted by: Waqar.

Author
Posts
#2214311

Tell us what you are trying to do?

I got help with some CRED form email notifications here: https://toolset.com/forums/topic/need-help-with-cred-form-notification/

We have since taken the site live, but now the emails are returning this value "%%FIXED_PARENT_TITLE%%" instead of the correct parent post information. What do I need to update to fix this problem?

Thank you!

What is the link to your site?
ironrockdressage.com

#2215443

Hi,

Thank you for contacting us and I'd be happy to assist.

Can you please confirm, if the custom code from Jamal's reply ( ref: https://toolset.com/forums/topic/need-help-with-cred-form-notification/#post-2194055 ) is still added and active on the website?

Also, if you've changed the relationship slugs on the live website, you'll also have to update them in the code snippet, accordingly.

In case the issue still persists, you're welcome to share temporary admin login details of the live website, along with the link to the page where this form can be seen.

Note: Your next reply will be private and it is recommended to make a complete backup copy, before sharing the access details.

regards,
Waqar

#2217505

Thank you for sharing the admin access.

I've performed some tests on my website with a similar form and settings and it turns out, you'll need to replace the custom code at WP Admin -> Toolset -> Settings -> Custom Code, with this updated snippet:


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 ) {
	if(!empty($_REQUEST['@horse-sale-horse-inquiry_parent'])) {
		$parent_id = $_REQUEST['@horse-sale-horse-inquiry_parent'];
		$newPlaceHolders = array(
			'%%FIXED_PARENT_TITLE%%' => get_the_title($parent_id),
			'%%FIXED_PARENT_LINK%%' => get_permalink($parent_id)
		);
	}
	
	if(!empty($_REQUEST['@event-event-inquiry_parent'])) {
		$event_id = $_REQUEST['@event-event-inquiry_parent'];
		$newPlaceHolders = array(
			'%%FIXED_EVENT_TITLE%%' => get_the_title($parent_id),
			'%%FIXED_EVENT_LINK%%' => get_permalink($parent_id)
		);
	}

	return array_merge($defaultPlaceHolders, $newPlaceHolders );
}

This code works in my test website and should work on your's too.

#2218045

I added the new code, but it still isn't working.

#2218515

I've performed some more tests on my website and the same code works.

Do I have your permission to download a clone/snapshot of your website, to investigate this on a test server?

#2220929

Yes. Please do. Sorry for the delayed response.

#2222087

Thank you for the permission and I've created a clone of your website.

I'll be performing some tests and will share my findings, as soon as this testing completes.

#2223179

Thank you for waiting.

During troubleshooting, I noticed that the code for the custom placeholder text is not working for the form "Sales Horse Contact Form", because the field "Horses Sales Horse Inquiries" is added inside the conditional field group, which never shows.

The fields hidden through the conditional field groups are disabled, which is why no value is passed for this field in the form's submission. The code snippet for the custom placeholder depends on this field's value, so it doesn't work either.

You can move that "Horses Sales Horse Inquiries" field out from the conditional field group and show it directly, so that it is the last field in the form.
( screenshot: hidden link )

In the form's CSS code, you can include some CSS code to hide this last field from visitors:


form.cred-form .form-group:last-of-type {
    display: none;
}

After these changes, please check the form again and the custom placeholder text will work.

You can fix this for any other form, where you've hidden the relationship field using the conditional group, and where custom placeholder text is not working.

#2224375

Thank you Waqar, that fixed it. How weird that it was working when the site was in development.

My issue is resolved now. Thank you!