This support ticket is created Il y a 2 années et 11 mois. 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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
I created a feedback form that works by creating a post in the "Messages" custom post type and then uses the code below to send an e-mail to a dynamic recipient. It works just fine except that, periodically, it will randomly stop working altogether. It tends to happen when the theme (Astra) requires updating. This is a bit of a nuisance and I'm wondering if there is anything in my code that could be improved to prevent this from happening.
Example Form: hidden link
// modify recipient to parent of the message post
add_filter('cred_notification_recipients', 'modify_recipients', 10, 4);
function modify_recipients($recipients, $notification, $form_id, $post_id) {
// Check notification name matches target notification
if ( isset($notification['name']) && 'Dynamic E-Mail Recipient' == $notification['name'] ) {
// Add email recipient
$parent_id = toolset_get_related_post(
$post_id,
'position-message'
);
$emailemailangehorige = get_post_meta($parent_id, 'wpcf-position-e-mail', true);
$recipients[0] = array(
'to' => 'to',
'address' => $emailemailangehorige,
'name' => '',
'lastname' => '');
}
return $recipients;
}
// modify the from and reply-to information
add_filter('cred_mail_header', 'customise_cred_notifications', 10, 5);
function customise_cred_notifications( $headers, $formid, $postid, $notification_name, $notification_number ) {
if ($formid==68 && $notification_name=='Dynamic E-Mail Recipient') {
$sendername = get_post_meta($postid,'wpcf-message-name',true);
$senderemail = get_post_meta($postid,'wpcf-message-e-mail',true);
$myheaders = array('Reply-To: '.$senderemail);
return array_merge($headers, $myheaders);
}
return $headers;
}
Replying to keep this ticket open. I found out this morning the e-mails are still not working (despite working when I first opened this ticket). I will have to investigate further, and will try putting into debug mode as you suggested.