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 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.
This topic is split from https://toolset.com/forums/topic/grant-revoke-access-to-image-visibility-based-on-user/
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 4 years, 11 months ago.
Assisted by: Christian Cox.