Appointments Plugin Sending emails to one address?

Hello,

How can I have new appointment emails go to one specific email address versus the service provider or to the site admin? I don’t want emails going to the site admin when no service provider is selected and I would like the email going to one specific email address if either service providers is selected.

Thank you

  • ticadmin
    • The Incredible Code Injector

    Hello Vaughan and thank you for your response.

    As I understand it, wouldn’t the edits suggested cause ALL admin related emails to go to the “youremail@email.com” address and not only specifically the ones associated with new appointments?

    Thanks

  • Vaughan
    • Support/SLS MockingJay

    Hi,

    That shouldn’t affect the plugin like that, so something else is likely causing it.

    I do see some JS errors on your page which could be the cause.

    Invalid App Id: Must be a number or numeric string representing the application id.

    connect.facebook.net/en_US/all.js:64 FB.getLoginStatus() called before calling FB.init().

    connect.facebook.net/en_US/all.js:64 FB.init has already been called – this could indicate a problem

    connect.facebook.net/en_US/all.js:64 Invalid App Id: Must be a number or numeric string representing the application id.

    connect.facebook.net/en_US/all.js:64 FB.getLoginStatus() called before calling FB.init().

    This looks to be related to facebook, can you try disabling whatever FB plugin you have and try again?

    Thanks

  • ticadmin
    • The Incredible Code Injector

    Thank you.

    Apparently the appointments were made, however, no confirmation message was popping up. Prior to the edits suggested the confirmation was coming up no problem so it seems it was the edits and not the FB plugin which is causing that.

    Also, emails are still not going to the “youremail@email.com” account and only to the provider. Perhaps I can grant access and you could take a look?

  • ticadmin
    • The Incredible Code Injector

    Hello Vaughan,

    I just extended access. Could you take a look to see if everything is set up properly?

    I’d like all appointment requests to go to info@procarekc.com and not go specifically go to the individual service provider. Also, there is no confirmation popup for the user when requesting an appointment.

  • Ash
    • WordPress Hacker

    Hello @ticadmin

    I hope you are well today.

    If you remove Vaughan’s code, do you see confirmation message then? If not, then this code is not breaking the confirmation message.

    Also, for email, would you please replace his code with the following:

    add_filter( 'app_get_admin_email', 'app_get_admin_email_cb' );
    function app_get_admin_email_cb( $email ){
    return 'info@procarekc.com';
    }

    You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name ‘mu-plugins’. If there is no folder in that name, then create a folder, name it ‘mu-plugins’, create a file inside that, give any name you like and paste the code in there. You don’t need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers

    Ash

  • ticadmin
    • The Incredible Code Injector

    Hi Vaughan,

    Thank you for your reply. I tried adding the second email address as follows with both a space and no space after the comma but it only sends a notification FROM the first address and does not send a notification to either email listed below. We need to be able to send a notification to two emails once a user schedules an appointment. When I check the logs it shows that it is only showing that confirmation emails are being sent to the user.

    `add_filter( ‘app_get_admin_email’, ‘app_get_admin_email_cb’ );

    function app_get_admin_email_cb( $email ){

    return ’email1@gmail.com,email2@gmail.com’;

    }

  • Ash
    • WordPress Hacker

    Hi there

    Use my above code that was working before.

    In addition, add the following code to send email to another email:

    add_action( 'app_new_appointment', 'app_new_appointment_cb', 99, 1 );
    function app_new_appointment_cb( $app_id ){
    wp_mail(
    'email@gmail.com',
    'subject',
    'content'
    );
    }

    or

    add_action( 'app_confirmation_sent', 'app_confirmation_sent_cb', 99, 3 );
    function app_confirmation_sent_cb( $body, $r, $app_id ){
    global $appointments;
    $to = 'email@gmail.com';

    $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 .= "nnn";

    wp_mail(
    $to,
    $appointments->_replace( __('New Appointment','appointments'), $r->name, $appointments->get_service_name( $r->service), $appointments->get_worker_name( $r->worker), $r->start, $r->price, $appointments->get_deposit($r->price), $r->phone, $r->note, $r->address, $r->email, $r->city ),
    $provider_add_text . $body,
    $appointments->message_headers( )
    );
    }

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers

    Ash

  • ticadmin
    • The Incredible Code Injector

    Hi Ash and thank you for your response.

    I added the code that previously worked and then tried both of your codes from your reply above.

    The first one worked however, I need to be able to pull the content from the appointment request and do not know how to add that.

    The second code looks like it is suppose to do exactly that however when I tested it, it did not send the email to the email address inserted.

    Thank you for your continued assistance on this.

  • Ash
    • WordPress Hacker

    Hi there

    Please try the following code:

    add_action( 'app_new_appointment', 'app_new_appointment_cb', 99, 1 );
    function app_new_appointment_cb( $app_id ){

    global $wpdb;
    $r = $wpdb->get_row( $wpdb->prepare("SELECT * FROM {$this->app_table} WHERE ID=%d", $app_id) );
    if ( $r != null ) {
    if (empty($r->email) && !empty($r->user) && (int)$r->user) {
    $wp_user = get_user_by('id', (int)$r->user);
    if ($wp_user && !empty($wp_user->user_email)) $r->email = $wp_user->user_email;
    }

    $body = apply_filters( 'app_confirmation_message', $this->add_cancel_link( $this->_replace( $this->options["confirmation_message"],
    $r->name, $this->get_service_name( $r->service), $this->get_worker_name( $r->worker), $r->start, $r->price,
    $this->get_deposit($r->price), $r->phone, $r->note, $r->address, $r->email, $r->city ), $app_id ), $r, $app_id );

    $mail_result = wp_mail(
    'email@gmail.com',
    $this->_replace( $this->options["confirmation_subject"], $r->name,
    $this->get_service_name( $r->service), $this->get_worker_name( $r->worker),
    $r->start, $r->price, $this->get_deposit($r->price), $r->phone, $r->note, $r->address, $r->email, $r->city ),
    $body,
    $this->message_headers( ),
    apply_filters( 'app_confirmation_email_attachments', '' )
    );
    }

    }

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers

    Ash

  • Ash
    • WordPress Hacker

    Okay, another version. It should fix the previous issue:

    add_action( 'app_new_appointment', 'app_new_appointment_cb', 99, 1 );
    function app_new_appointment_cb( $app_id ){

    global $wpdb, $appointments;
    $r = $wpdb->get_row( $wpdb->prepare("SELECT * FROM {$appointments->app_table} WHERE ID=%d", $app_id) );
    if ( $r != null ) {
    if (empty($r->email) && !empty($r->user) && (int)$r->user) {
    $wp_user = get_user_by('id', (int)$r->user);
    if ($wp_user && !empty($wp_user->user_email)) $r->email = $wp_user->user_email;
    }

    $body = apply_filters( 'app_confirmation_message', $appointments->add_cancel_link( $appointments->_replace( $appointments->options["confirmation_message"],
    $r->name, $appointments->get_service_name( $r->service), $appointments->get_worker_name( $r->worker), $r->start, $r->price,
    $appointments->get_deposit($r->price), $r->phone, $r->note, $r->address, $r->email, $r->city ), $app_id ), $r, $app_id );

    $mail_result = wp_mail(
    'email@gmail.com',
    $appointments->_replace( $appointments->options["confirmation_subject"], $r->name,
    $appointments->get_service_name( $r->service), $appointments->get_worker_name( $r->worker),
    $r->start, $r->price, $appointments->get_deposit($r->price), $r->phone, $r->note, $r->address, $r->email, $r->city ),
    $body,
    $appointments->message_headers( ),
    apply_filters( 'app_confirmation_email_attachments', '' )
    );
    }

    }

    Please let me know how it goes.

    Cheers

    Ash

  • ticadmin
    • The Incredible Code Injector

    Hi Ash,

    Unfortunately it did not work all the way.

    I used the code above plus the other piece of code that was working. I’ve copied it below so you can see what I’m using (with my emails entered of course).

    With this code combination I received the user confirmation email from emailFROM@gmail.com however I did not received the the notification at emailTO@gmail.com. Also, I need the notifcations to be able to go to two emails. Thank you

    `

    add_filter( ‘app_get_admin_email’, ‘app_get_admin_email_cb’ );

    function app_get_admin_email_cb( $email ){

    return ’emailFROM@gmail.com’;

    }

    add_action( ‘app_new_appointment’, ‘app_new_appointment_cb’, 99, 1 );

    function app_new_appointment_cb( $app_id ){

    global $wpdb, $appointments;

    $r = $wpdb->get_row( $wpdb->prepare(“SELECT * FROM {$appointments->app_table} WHERE ID=%d”, $app_id) );

    if ( $r != null ) {

    if (empty($r->email) && !empty($r->user) && (int)$r->user) {

    $wp_user = get_user_by(‘id’, (int)$r->user);

    if ($wp_user && !empty($wp_user->user_email)) $r->email = $wp_user->user_email;

    }

    $body = apply_filters( ‘app_confirmation_message’, $appointments->add_cancel_link( $appointments->_replace( $appointments->options[“confirmation_message”],

    $r->name, $appointments->get_service_name( $r->service), $appointments->get_worker_name( $r->worker), $r->start, $r->price,

    $appointments->get_deposit($r->price), $r->phone, $r->note, $r->address, $r->email, $r->city ), $app_id ), $r, $app_id );

    $mail_result = wp_mail(

    ’emailTO@gmail.com’,

    $appointments->_replace( $appointments->options[“confirmation_subject”], $r->name,

    $appointments->get_service_name( $r->service), $appointments->get_worker_name( $r->worker),

    $r->start, $r->price, $appointments->get_deposit($r->price), $r->phone, $r->note, $r->address, $r->email, $r->city ),

    $body,

    $appointments->message_headers( ),

    apply_filters( ‘app_confirmation_email_attachments’, ” )

    );

    }

    }

  • Ash
    • WordPress Hacker

    Hi there

    When I test, I can see the data is sending correctly, screenshot attached.

    Would you please send me login details and FTP details?

    To send me details, please use our contact form: https://premium.wpmudev.org/contact/

    Select: I have a different question

    Subject: Attn-Ash (this ensures that it will be assigned to me)

    Details:

    1. Send all requested details

    2. Send a link of this thread so that I can track

    3. Send any other relevant link

    I will be happy to take a look :slight_smile:

    Cheers

    Ash

  • ticadmin
    • The Incredible Code Injector

    Hi Ash,

    The client seems to think that the he was receiving notifications at two separate email addresses before and was wondering if there was an update that may have changed things. He says he was receiving it at both the emails up until about 2 months ago.

    “Was there an update that took away the option to add/change email addresses?

    I know it used to be there when we first set it up. I remember seeing the two email addresses listed, and as you know, now the whole option is gone. Just curious.”

  • Ash
    • WordPress Hacker

    Hello @ticadmin

    In that case, I think there was custom customization added in the core plugins. So, when the plugin is updated the changes was lost.

    And the other way is, the email is sent to admin email and service provider email. Maybe your client is talking about these two emails?

    Cheers

    Ash

  • Ash
    • WordPress Hacker

    Hi there

    I didn’t get any information from your account. I have just checked our system and it was Apr 16 when you last sent some information.

    So, would you please follow the procedure again?

    To send me details, please use our contact form: https://premium.wpmudev.org/contact/

    Select: I have a different question

    Subject: Attn-Ash (this ensures that it will be assigned to me)

    Details:

    1. Send all requested details

    2. Send a link of this thread so that I can track

    3. Send any other relevant link

    Cheers

    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.