Appointment Form Issue
This support request was posted in Paeon by dentprio
- dentprio May 24, 2016 at 11:49 pm
Having an issue with the Appointment form. For some reason it’s pulling the email address used in the form to send the email from. Is there any way to edit the appointment form php file so I can set what email address the form is sent from?
I host the website with dreamhost and the only way the appointment form will work is if the form is sent from an email address that is being hosted through dreamhost.
Thanks so much for any help!
Juanfra Aldasoro May 25, 2016 at 3:38 pmHi,
Thank you for writing. The email form from address is pulled from the user that is requesting the appointment.
The php script that is in charge of sending the email out is in /paeon/includes/ajax.php, in the function nice_appointment_ajax()
Best,
Juan.dentprio May 25, 2016 at 4:26 pmHi Juanfra, thanks for you reply! Could you help show me where I would need to edit the ajax.php file? I’m looking at it but I’m not sure what I should change in the file to specify the email address… I’m not too familiar with PHP. Thanks so much, Alex.
function nice_appointment_ajax() {
global $nice_options;
check_ajax_referer( ‘play-nice’, ‘nonce’ );
if ( ! empty( $_POST ) ) {
$admin_email = $_POST[‘target’];
if ( ! nice_bool( $admin_email) ) {
$admin_email = get_option( ‘nice_email’ );if ( trim( $admin_email ) == ” )
$admin_email = get_bloginfo( ‘admin_email’ );
}$name = $_POST[‘name’];
$date = $_POST[‘date’];
$phone = $_POST[‘phone’];
$mail = $_POST[‘mail’];
$msg = $_POST[‘message’];$error = ”;
if ( ! $name ) {
$error .= __( ‘Please tell us your name’, ‘nicethemes’ ) . “”;
}
if ( ! $date ) {
$error .= __( ‘Please insert an appointment date’, ‘nicethemes’ ) . “”;
}
if ( ! $mail ) {
$error .= __( ‘Please tell us your E-Mail address’, ‘nicethemes’ ) . “”;
}
if ( ! $msg ) {
$error .= __( ‘Please add a message’, ‘nicethemes’ );
}if ( empty( $error ) ) {
$mail_subject = ‘[‘ . get_bloginfo( ‘name’ ) . ‘] ‘ . __( ‘New Appointment form received’, ‘nicethemes’ );
$body = __( ‘Name: ‘, ‘nicethemes’ ) . “$name \n\n”;
$body .= __( ‘Date: ‘, ‘nicethemes’ ) . “$date\n\n”;
$body .= __( ‘Phone: ‘, ‘nicethemes’ ) . “$phone\n\n”;
$body .= __( ‘Email: ‘, ‘nicethemes’ ) . “$mail \n\n” . __( ‘Message: ‘, ‘nicethemes’ ) . “$msg”;$headers[] = __( ‘From: ‘, ‘nicethemes’ ) . $name . ‘ ‘;
$headers[] = __( ‘Reply-To: ‘, ‘nicethemes’ ) . $mail ;
$headers[] = “X-Mailer: PHP/” . phpversion();if ( $sent = wp_mail( $admin_email, $mail_subject, $body, $headers ) ) {
_e( ‘Thank you for leaving a message.’, ‘nicethemes’ );
} else {
_e( ‘There has been an error, please try again.’, ‘nicethemes’ );
}} else {
echo $error;
}
}
die();
}
endif;if ( ! function_exists( ‘nice_masonry_blog_ajax’ ) ) :
add_action( ‘wp_ajax_nopriv_nice_more_posts_loader’, ‘nice_masonry_blog_ajax’ );
add_action( ‘wp_ajax_nice_more_posts_loader’, ‘nice_masonry_blog_ajax’ );Juanfra Aldasoro May 25, 2016 at 8:12 pmHi,
Thank you for your prompt response.
You need to change the $name and $email variables in order to change the “From” email.
Something like:
$name = 'John Doe'; $email = 'john@doe.com';
You can put that after the following line:
$body .= __( ‘Email: ‘, ‘nicethemes’ ) . “$mail \n\n” . __( ‘Message: ‘, ‘nicethemes’ ) . “$msg”;
Best,
Juan.dentprio May 25, 2016 at 10:06 pmLike this?
if ( empty( $error ) ) {
$mail_subject = ‘[‘ . get_bloginfo( ‘name’ ) . ‘] ‘ . __( ‘New Appointment form received’, ‘nicethemes’ );
$body = __( ‘Name: ‘, ‘nicethemes’ ) . “$name \n\n”;
$body .= __( ‘Date: ‘, ‘nicethemes’ ) . “$date\n\n”;
$body .= __( ‘Phone: ‘, ‘nicethemes’ ) . “$phone\n\n”;
$body .= __( ‘Email: ‘, ‘nicethemes’ ) . “info@auroradentalgroup.com \n\n” . __( ‘Message: ‘, ‘nicethemes’ ) . “$msg”;$headers[] = __( ‘From: ‘, ‘nicethemes’ ) . $name . ‘ ‘;
$headers[] = __( ‘Reply-To: ‘, ‘nicethemes’ ) . $mail ;
$headers[] = “X-Mailer: PHP/” . phpversion();if ( $sent = wp_mail( $admin_email, $mail_subject, $body, $headers ) ) {
_e( ‘Thank you for leaving a message.’, ‘nicethemes’ );
} else {
_e( ‘There has been an error, please try again.’, ‘nicethemes’ );
}Juanfra Aldasoro May 25, 2016 at 10:47 pmNo, like this:
if ( empty( $error ) ) { $mail_subject = '[' . get_bloginfo( 'name' ) . '] ' . __( 'New Appointment form received', 'nicethemes' ); $body = __( 'Name: ', 'nicethemes' ) . "$name \n\n"; $body .= __( 'Date: ', 'nicethemes' ) . "$date\n\n"; $body .= __( 'Phone: ', 'nicethemes' ) . "$phone\n\n"; $body .= __( 'Email: ', 'nicethemes' ) . "$mail \n\n" . __( 'Message: ', 'nicethemes ' ) . "$msg"; $name = 'John Doe'; $mail = 'john@doe.com';
Best,
Juan.dentprio May 25, 2016 at 10:55 pmThank you so much! It’s working just fine now.
Last question while I have this appointment form support post open, where would I go to delete the “Appointment Date” item from the form?
Juanfra Aldasoro May 25, 2016 at 11:02 pmHi,
Thank you for the follow up. Unfortunately we cannot bring support on exhaustive customizations. We’ve created an article explaining why is that we limit our support to theme related issues and bugs: http://nicethemeswp.com/article/support-vs-customizations/
The appointment form is created in the widget() method in /paeon/includes/widget/widget-appointments.php
Best,
Juan.
You must be logged in to reply to this topic.