Need to send multiple admin notifications

When a new appointment comes in, as I understand, the admin notification goes to the site admin set under Settings. I manage the site so I am the site admin. However, I am not the site owner or someone who needs to be notified of new appointments.

There are two email addresses (not mine) that should be notified of new appointments. My questions are:

* Is it correct that the admin notification is currently only going to the site admin set under Settings

* If yes, is it possible to send email notifications to multiple email addresses? I think the easiest would be to send to all admin users rather than the site admin alone.

  • Dimitris
    • Support Star

    Hello Sara,

    hope you're doing well and thanks for reaching us!

    Is it correct that the admin notification is currently only going to the site admin set under Settings

    This is true and that's by design. There's a filter though that you could use in a little MU plugin file, like: wp-content/mu-plugins/app-admin-email.php
    (simply create the /mu-plugins/ folder if it doesn't exist already)
    and insert the exact code in there:

    <?php
    add_filter(  'app_get_admin_email',  'youremail@email.com', 999, 1 );

    About having multiple email addresses, I've asked our Second Level Support team about it, to check if we could accomplish this with some code. The alternative can be to set a forwarder in the email client of first admin user. I'll keep you posted here as soon as there're any insights on this. :slight_smile:

    Hope that was some help!
    Warm regards,
    Dimitris

  • Dimitris
    • Support Star

    Hello again Sara

    Please replace the content of the above MU plugin file with the following:

    <?php
    add_filter( 'app_confirmation_disable_admin', function( $disable, $app, $app_id, $admin_email ) {
    
      $appointments = appointments();
      $receivers = array( 'reveiverone@test.com', 'reveivertwo@test.com', 'reveivertjree@test.com' );
      $notification_manager = new Appointments_Notifications_Manager();
      $confirmation_obj = new Appointments_Notifications_Confirmation( $notification_manager );
    
      $template = $confirmation_obj->get_admin_template( $app_id );
    
      if ( ! $template ) {
          return false;
      }
    
      $result =  wp_mail(
          $receivers,
          $template['subject'],
          $template['body'],
          $appointments->message_headers()
      );
    
      if ( $result ) {
          do_action( 'appointments_confirmation_admin_sent', $admin_email, $app_id, $template['body'], $template['subject'] );
      }
    
      return true;
    }, 20, 4 );

    Then edit this line
    $receivers = array( 'reveiverone@test.com', 'reveivertwo@test.com', 'reveivertjree@test.com' );
    insert the email addresses you need for your admin users and you should be set! :slight_smile:

    Warm regards,
    Dimitris

  • Sara
    • Flash Drive

    This code did not work. I put tried adding the code two ways:

    * In functions.php in child theme --> This resulted in no changes. No emails went out.

    * in wp-content/mu-plugins/app-admin-email.php --> This caused the appointment tool to stop working. When you select a time slot, the loading icon appeared, but the appointment fields never loaded. Everything froze so could not complete appointment request.

  • Nastia
    • Support Rock Star

    Hello Sara

    I trust you are doing well!

    I've tested the code on my end and I am afraid it didn't work either. I've flagged our second level support developers so they could provide some feedback regarding this code. We will follow up in this thread with an update.

    Have a good day and take care!

    Cheers,
    Nastia

  • Panos
    • SLS

    Hi Sara !

    This wouldn't work if the user that makes the appointment is the worker of the service, in which case the confirmation notification is not sent to admin. Appointments plugins checks if the emails are same and doesn't send confirmation to admin.

    Could you please create a test user and make an appointment with that user? Then confirm and check if the email has been sent to multiple receivers you .

    Kind regards!

  • Sara
    • Flash Drive

    Hi Panos,

    Not sure I'm clear. When you say "worker" are you referring to Service Provider or just a WordPress user? In case you mean Service Provider, we aren't using those.

    I tried making an appointment logged in as the site admin but also not logged in at all as any user. Neither scenario sent email notifications to the additional emails per the provided code.

    I do receive the site admin notification, but that is it.

  • Panos
    • SLS

    As it works on my test site and checked on Nastia's site and works there too, could you share admin and ftp access so I could have a look on your site? I might have to a few test appointments and try troubleshoot why it's not sending.

    You can send that privately through our contact form: https://premium.wpmudev.org/contact/#i-have-a-different-question

    Send in:Subject: "Attn: Panos Lyrakis"

    - Admin login:
    Admin username
    Admin password
    Login url

    - FTP credentials
    host
    username
    password
    (and port if required)

    - link back to this thread for reference

    Kind regards!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.