How Do I Send Notification of Appointments to Two Email Addresses?

Hi,
I would like appointment request emails to be sent to more than one email address. Could you please help me figure out how to make this work? I have an attorney and his secretary that both need to be notified when an appointment is made.

Thank you for your help.

  • Jack Kitterhing
    • Code Norris

    Hi there @jdanker,

    Hope you're well today and thanks for your question.

    This isn't currently possible out of the box, but I have flagged the lead developer for his valuable input here, on if this can be done with a filter or hook at all :slight_smile:

    Thanks for your patience.

    Kind Regards
    Jack.

  • Vladislav
    • Dead Eye Dev

    Hello,

    Each time a new appointment is made, the "app_new_appointment" hook will be triggered. We can use this to our advantage in this scenario, and send an additional email with some custom code, like this:

    function my_app_send_additional_emails ($app_id) {
    	wp_mail(
    		'additional_one@email.com',
    		'Subject line',
    		'Email message body'
    	);
    	wp_mail(
    		'additional_two@email.com',
    		'Subject line',
    		'Email message body'
    	);
    }
    add_action("app_new_appointment", "my_app_send_additional_emails");

    This is, of course, a simplistic example - it will just send out two more very simple messages to fixed email addresses every time an appointment is created. It won't, for an example, check the appointment status (e.g. whether it's confirmed, paid for or not etc), or include any of the appointment data. However, it's a start - the action also receives the newly created appointment ID, so all that information can be included in the email relatively easily. I hope this can get you started, but if this is too simplistic for your needs, I'd be glad to provide a bit more detailed and useful code if you let us know a bit more details, e.g. what kind of appointment info should go in the emails, or any other conditions checks that might be needed.

  • jdanker
    • Flash Drive

    Thank you!!

    In theory, this solution should work great, however when I use the code above - both as is and with proper email addresses - I receive an error:

    "Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION...."

    Any ideas?

  • Vladislav
    • Dead Eye Dev

    Hello,

    I am really sorry for omitting this info originally - this code was meant to be used outside the plugin files. Editing the plugin files directly, although entirely doable, isn't exactly great, because then you will lose your customizations every time you update your plugin. This is why the customizations such as these are best kept separate.

    Anyway, you can put the code above in your theme's functions.php, or in a mu-plugin. A mu-plugin is a .php file in your wp-content/mu-plugins directory (you can just create it if it doesn't exist), and they will always be loaded with your site. If you decide to go with the mu-plugin approach, please remember to add the opening "<?php" tag at the beginning of the file, before everything else.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.