Problem: I have added some custom code using the CRED API which should modify the notification email recipients list and include the parent post's author email address. It does not seem to be working.
Solution: Check the syntax and be sure your variables are correct. In this case the parent_post_author_id variable was not correctly identified with a $. The corrected code is:
/ Notification add_filter('cred_notification_recipients', 'my_cred_notification_recipients_func', 10, 4); function my_cred_notification_recipients_func($recipients, $notification, $form_id, $post_id){ if (204 == $form_id){ $parent_slug = "opdracht"; $field_slug = '_wpcf_belongs_' . $parent_slug . '_id'; $parent_post_id = get_post_meta($post_id, $field_slug, true); $parent_post_author_id = get_post_field ('post_author', $parent_post_id ); $author_email = get_the_author_meta('user_email', $parent_post_author_id ); $recipients[] = array('to'=>'to', 'name'=>'', 'lastname'=>'', 'address'=>$author_email ); } return $recipients; }
Relevant Documentation:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_notification_recipients
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 4 replies, has 2 voices.
Last updated by 6 years, 9 months ago.
Assisted by: Christian Cox.