Need to add to admin email sent to provider

Hi, my client (the "service provider") needs a little more information added to the email he receives notifying him that an appointment needs confirmation.

Currently this email notification states: "The new appointment has an ID ___ for (DATE and TIME) and you can confirm it using your profile page."

If he needs to decline the selected appointment for example, it would be great if the email could including the requesting client's email address.

Also, is it possible to add a link to at least his Dashboard, or to his Profile rather than just the text about confirming it using his profile page?

He would be apprehensive about clicking around the backend/admin area searching for what he needs (like the requesting person's email address).

Thanks so much for your time! :o)

Melinda

  • Vaughan

    Hi @melinda,

    You should be able to add the following to your confirm & cancellation emails.

    For the above email subject and message contents, you can use the following placeholders which will be replaced by their real values: SITE_NAME, CLIENT, SERVICE, SERVICE_PROVIDER, DATE_TIME, PRICE, DEPOSIT, BALANCE, PHONE, NOTE, ADDRESS, CITY, EMAIL (Client's email), CANCEL (Adds a cancellation link to the email body)

    So if you add EMAIL to the content body of each notification email in

    Dashboard > appointments > settings > general > notification settings section.

    Then the clients email will be included in the email.

    Hope this helps

  • Melinda

    Hi Vaughan,

    Thanks for your reply, but I'm referring to a notification email that cannot be edited via the Appointments+ general settings.

    This is the email that is sent to the service provider to tell them there is a pending appointment needing their confirmation.

    I need that email to give the service provider the client's email address and a link to the Dashboard or better yet, directly to their Profile page.

    I can see the code for it in the appointments.php file, but a. I wouldn't know how to alter it even if that was the best thing to do and b. was wondering if there was a way to do it that won't be wiped out when I update the plugin.

    Thanks!

  • Jack Kitterhing

    Hi there @Melinda,

    Hope you're well today! :slight_smile:

    I've been discussing this with one of our developers and after some testing this should work for you.

    function my_app_send_my_own_confirmation ($body, $app, $app_id) {
    global $appointments;
    
    $body .= "Client email: {$app->email}\n"; // ... and whatever else
    $to = array( $appointments->get_admin_email( ) );
    
    $worker_email = $appointments->get_worker_email( $r->worker );
    if ( $worker_email )
    $to[]= $worker_email;
    
    $provider_add_text  = sprintf( __('A new appointment has been made on %s. Below please find a copy of what has been sent to your client:', 'appointments'), get_option( 'blogname' ) );
    $provider_add_text .= "\n\n\n";
    
    wp_mail(
    $to,
    __('New Appointment','appointments'),
    $provider_add_text . $body,
    $appointments->message_headers( )
    );
    
    add_filter('app_confirmation_disable_admin', '__return_true');
    }
    add_filter('app_confirmation_sent', 'my_app_send_my_own_confirmation', 10, 3);

    You can add that in the functions.php of your active theme.

    Here we're actually overriding the default email that gets sent to admin/workers and instead are sending our own custom version.

    Any questions or concerns please don't hesitate to ask.

    Thanks!

    Kind Regards
    Jack.

  • Melinda

    Hi Jack! :slight_smile:

    I added that code and tested and am not sure where the changes are/if they are anywhere.

    Is that code for editing the admin email that is sent AFTER the appointment is confirmed by admin or the one that is sent before?

    It looks like it's for the one that is sent after. To clarify, I need to alter the email that is sent before confirmation, the one the client never sees. It's just a notification to the service provider telling them to confirm an appointment.

    Thanks so much!
    Melinda

  • Vinod Dalvi

    Hi Melinda,

    Try adding the following code in the functions.php file of your child theme to change the provider email to include client's email address and his profile page link.

    function app_messages_worker_custom_notification( $body, $r, $app_id ){
    
    	$time_format = get_option('time_format');
    	if (empty($time_format)) $time_format = "H:i";
    
    	$date_format = get_option('date_format');
    	if (empty($date_format)) $date_format = "Y-m-d";
    
    	$datetime_format = $date_format . " " . $time_format;
    
    	$body = sprintf(__('The new appointment has an ID %s for %s and you can confirm it using your profile page %s.','appointments'), $app_id, date_i18n($datetime_format, strtotime($r->start)), admin_url( 'profile.php' ));
    
    	$body .= "\n\n Client's email address : ". $r->email;
    	return  $body;
    }
    add_filter('app-messages-worker-notification', 'app_messages_worker_custom_notification', 10, 3);

    You can also change the email subject by using the following code.

    function app_messages_worker_custom_notification_subject( $subject, $r, $app_id ){
    
    	$subject = __('An appointment requires your confirmation', 'appointments');
    	return  $subject;
    }
    add_filter('app-messages-worker-notification-subject', 'app_messages_worker_custom_notification_subject', 10, 3);

    Best Regards,
    Vinod Dalvi

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.