Skip Navigation

[Resolved] PARENT_POST_TITLE not working in email send by form

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to include the parent post title in an email notification triggered by a Form that creates private child posts. Unfortunately the %%PARENT_POST_TITLE%% placeholder is not working as expected.

Solution: The best solution here is to create custom placeholders using the Forms API, and use the post relationships API in those placeholders to display information from the parent post.

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 ) {
  $parent_id = $_REQUEST['@book-chapter_parent'];
  $newPlaceHolders = array(
    '%%FIXED_PARENT_TITLE%%' => get_the_title($parent_id),
    '%%FIXED_PARENT_LINK%%' => get_permalink($parent_id)
  );
 
  return array_merge($defaultPlaceHolders, $newPlaceHolders );
}

Then in your notification you can use them like other placeholders:

Parent post title: %%FIXED_PARENT_TITLE%%
Parent post link: %%FIXED_PARENT_LINK%%

In your case you would change @book-chapter_parent to match your post relationship slug. Yours would be @tessuti_richiesta-info_parent. Notice that the "dot" usually seen in the post relationship slug is replaced with an underscore here.

Relevant Documentation:
https://toolset.com/documentation/user-guides/front-end-forms/how-to-use-custom-placeholders-in-cred-notifications/

This support ticket is created 4 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 15 replies, has 2 voices.

Last updated by Silvia 4 years, 1 month ago.

Assisted by: Christian Cox.

Author
Posts
#1501943

After your message I decided to try to add the ID by myself and see what happens, and I succeeded. So, my problem is resolved and, as always, you were kind beyond words, helping me with this. THANK YOU!!!!!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.