Support » Plugin: Restaurant Reservations » How to send confirmation e-mail to client AND admin?

  • Dear support,
    hope you can help me.
    The purpose is that a copy of the confirmation e-mail, that is sended to the client, also goes to the admin. So there is a proof that the confirmation e-mail was sended.
    As far as I unerstood is the option with the checkbox only working when a new reservation is made, but not with te confirmation e-mail.

    Hope there is a solution for it?

    Kindest regards,

    jef

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author NateWr

    (@natewr)

    Hi @jefvandejumenas,

    Unfortunately, there is no easy way to do this. You would need to write a little bit of code to ensure a copy of each email is sent to the admin.

    If you’re familiar with WordPress’s hooks system and writing PHP code, you can add a BCC to every email this plugin sends to the user with the following code:

    
    add_action( 'rtb_send_notification_before', function( $email ) {
        if ( $email->target === 'user' ) {
            $email->headers .= "BCC: your@email.com\r\n";
        }
    } );
    

    And if you wanted to

    Hoi NateWr,

    thanks for reply.
    Am glad it is possible.
    I can “use” code a little bit. Am not that expert. HTML and css can do.
    Was wondering if I just could “copy paste” your code into the file Notification.Email.class.php at the end?

    Example:

    
    /**
    	 * Send notification
    	 * @since 0.0.1
    	 */
    	public function send_notification() {
    		wp_mail( $this->to_email, $this->subject, $this->message, $this->headers, apply_filters( 'rtb_notification_email_attachments', array(), $this ) );
    	}
    
    add_action( 'rtb_send_notification_before', function( $email ) {
        if ( $email->target === 'user' ) {
            $email->headers .= "BCC: jef@example.com\r\n";
        }
    } );
    
    }
    } // endif;
    

    I think you wanted to write more???

    Kindest regards,

    jef

    • This reply was modified 3 months, 2 weeks ago by  Jan Dembowski.

    Hi Jef, going through the gists of RR I found this little gist from Nate that I think your looking for. Please check it out: https://gist.github.com/NateWr/8bae55747b7861b1274eae739cf37086

    grtz.

    Thnx drrob67 for the tip (y)

    Hoi drrob67 is it possible that this a confirmation for “a pending reservation” ??? So and the client and the admin receive a notice that:
    1- a reservation is made by a client and is waiting to be approuved
    2- the admin gets a notice that a reservation was made by a client

    The purpose is that a copy of the email that goes to the client that confirms his reservation also goes to the admin.
    I’ve been looking through the code to find that paragrapgh where the confirmation is made .. and that there comes the piece of code that NateWr wrote.
    But I am still trying to find out where ..

    Hi Jef, I personnaly think that this is the confirmation where you confirm the booking there’s also coming a BCC to the admin email. But let me just test and i’l get back to you.

    grtz. Rob

    Ok Jef, I just tested it. And it’s indeed what I thought. So you as an admin will always et an email to inform you that someone made a reservation. Now when you sent the confirmation for the reservation you get nothing. With installing this little plugin that Nate wrote it does exactly what you want. It sents a copy of that confirmation mail to the admin address.
    But that is the only thing it does. So no adjustments can be made. I hope this is what you’re looking for.

    grtz. Rob

    Hoi drrob thanks for testing.
    This was what I was looking for. I know I can make no adjustments but the main part is that I receive the same email as the client> Some are not looking in their spam filter and the they say that they did not receive any mail at all.
    I “hooked” the little plugin from Nate into the last rule on the file Notification.Email.class.php

    /**
    * Send notification
    * @since 0.0.1
    */
    public function send_notification() {
    wp_mail( $this->to_email, $this->subject, $this->message, $this->headers, apply_filters( ‘rtb_notification_email_attachments’, array(), $this ) );
    }

    add_action( ‘rtb_send_notification_before’, function( $email ) {
    if ( $email->target === ‘user’ ) {
    $email->headers .= “BCC: jef@example.com\r\n”;
    }
    } );

    }
    } // endif;

    Do you think it’s the right way?
    Or do I have to search somewhere else??
    As I mentioned earlier … php is a little bit to high for me. To a certain degree I can understand what is happening.

    Sorry for the questions but I do not want to distroy the whole “restaurant-reservation” script in a way that it is not working any more.
    Thanks already for your effort.

    No no, there’s no need to get in the code. Just download the gist as a zip file. (top right corner) and upload the zip as plugin in your WP backend. This way you’ll get an extra plugin.

    Thanks drrob67,

    was and is helpfull (y)
    Appreciate it very much.

    jefvandejumenas

    Hoi drrob67 …
    1 more question …
    Do I have to delete manually the plugin in the /wp-content/plugins/ directory ???
    Or can I just download version 1.8.1 and install the new plugin and will this overwrite the existing file?? without doing any damage to the other functions?
    I think that I have to backup my translations and notifications that I already made with Loco Translate … because this will be overwritten??
    is that correct???

    No Jef, actually you have to assume that in WP you will never ever have to do something manually, at least for normal use. That said there are of course always some exceptions.
    But in this case you can just click in the plugin screen on Update plugin.
    Changes you’ve done like Loco translate will be held in the database and not be overwritten if a plugin is updated, At least it shouldn’t be. So to be safe all developers will ask you to just make sure you have a backup in case it fails. Just to be safe..
    So in your case, just update the plugin and it should work fine also with that other little plugin. This one is build on hooks and would not interfere with eachother.

    good luck

    Thnx a lot drrob67,

    (y)

    Plugin Author NateWr

    (@natewr)

    Thanks for all the help with support, @drrob67!

    NP @natewr

Viewing 15 replies - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.