Skip Navigation

[Cerrado] E-Mail Form Stops Working Periodically

This support ticket is created hace 3 años, 6 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Este tema contiene 3 respuestas, tiene 2 mensajes.

Última actualización por Waqar hace 3 años, 6 meses.

Asistido por: Waqar.

Autor
Mensajes
#2041649

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: enlace oculto

// 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;
	}
#2041881

Hi,

Thank you for contacting us and I'd be happy to assist.

Reading through the code that you've shared, I can't think of a reason it can conflict with the Avada theme's code or pending updates.

When it stops working, do you see any error or warning in the server's error logs? Do you have to do something, to make the code work again?

Next, time if this happens, I'll recommend turning on the WordPress debugging, and see if any error or warning is logged in the error log.
( ref: https://wordpress.org/support/article/debugging-in-wordpress/ )

Please let me know how it goes and if you have any further details.

regards,
Waqar

#2051555

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.

- Aaron

#2052731

Thanks for the update and I'll wait to hear back from you.

El debate ‘[Cerrado] E-Mail Form Stops Working Periodically’ está cerrado y no admite más respuestas.