Appointments+ admin notification custom receiver not working

Hello dear Team !

I have a small issue :
I have a custom code in a side-plugin to control who will receive notification asking an admin to confirm an appointment.

That code is this :

add_filter('app_notification_email', 'wpmudev_app_custom_mail',10, 3);
function wpmudev_app_custom_mail($mails, $r, $app_id){

	global $appointments;
	global $wpdb;
	$r = $wpdb->get_row( $wpdb->prepare("SELECT * FROM <code>ojKl098D_app_appointments</code> WHERE ID=%d", $app_id) );
	$id_sommelier = $r->worker;
	$sommelier = get_user_by( 'id', $id_sommelier  );
	$mails =  "guigro@gmail.com,contact@sommelierparticulier.com,". $sommelier->email ."";

	return $mails;

It worked until one of the last update of the plugin. I tried to find in the plugin code if something changed without any success.
Do you know where this might come from ?

Thanks a lot !
Regards,
Guillaume

  • Ivan Shulev

    Hey Guigro ,

    I hope you are having a nice day so far!

    I can see that the input variables of the filter are not 3, but 2:

    apply_filters( 'app_notification_email', $appointments->get_admin_email(), $r );

    So you are not receiving the 3rd parameter, which is $app_id.

    An easy fix would be to go to the /wp-content/plugins/appointments/includes/notifications/class-app-notification-notification.php and change line 15 from

    $admin_email = apply_filters( 'app_notification_email', $appointments->get_admin_email(), $r );

    to

    $admin_email = apply_filters( 'app_notification_email', $appointments->get_admin_email(), $r, $app_id );

    A better fix would be to use the information you currently have from your filter function. You can get the id from the $r variable.

    I hope this helps and I wish you an awesome day ahead!

    Ivan

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.