Appointment Form Issue

This support request was posted in Paeon by dentprio

Request ID #7116 In Progress
  • 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

    Hi,

    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.

    Hi 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

    Hi,

    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.

    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’ ) . “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’ );
    }

    Still doesn’t seem to be working for some reason :\

    Juanfra Aldasoro

    No, 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.

    Thank 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?

    And what exactly would I delete?

    Juanfra Aldasoro

    Hi,

    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.

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.

Login to your Account

Welcome back! Please log in to your account by filling the fields below:

Forgot?

Not a member? Create a free account.

Create a Free Account

You're 27 seconds away from some awesome WordPress free stuff, benefits and more. Create a free account and have access to our free products, benefits and more!

Already have an account? Log in
Secure Server