Problem: I would like to access the Post ID in the callback for a CRED email notification custom placeholder.
Solution:
You can access the Post ID in the defaultPlaceHolders array that is passed into the callback functions:
// custom cred form placeholders function custom_generic_field_notification( $defaultPlaceHolders ) { $post_id = $defaultPlaceHolders['%%POST_ID%%']; //generate random mail id $random_mail_id = get_post_meta($post_id, 'random-mail-id', true); if (empty($random_mail_id)) { $random_mail_id = bm_ajax_generate_random_mail_id($post_id); update_post_meta($post_id, 'random-mail-id', $random_mail_id); } $random_mail_id = '?mid='.$random_mail_id; $newPlaceHolders = array( '%%mid%%' => $random_mail_id ); return array_merge($defaultPlaceHolders, $newPlaceHolders ); } add_filter('cred_subject_notification_codes', 'custom_generic_field_notification', 10, 1); add_filter('cred_body_notification_codes', 'custom_generic_field_notification', 10, 1);
Relevant Documentation:
https://toolset.com/documentation/user-guides/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.
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 2 replies, has 2 voices.
Last updated by 6 years, 7 months ago.
Assisted by: Christian Cox.