Shannon (August 5th, 2013)
// Rewrite the contact listing owner form to remove website field function my_new_contact_form() { $result = array(); if ( empty( $_POST['post_id'] ) ) { $result['error'] = __( 'Contact Form submission error. Please try refreshing the page and submitting the contact form again.', APP_TD ); die ( json_encode( $result ) ); } if ( !wp_verify_nonce( $_POST['contact_nonce'], "va-contact-" . $_POST['post_id'] ) ) { $result['error'] = __( 'Contact Form submission error. Please try refreshing the page and submitting the contact form again.', APP_TD ); die ( json_encode( $result ) ); } $post_id = (int) $_POST['post_id']; $post = get_post( $post_id ); if ( !$post ) { $result['error'] = __( 'Contact Form submission error. Please try refreshing the page and submitting the contact form again.', APP_TD ); ob_start(); appthemes_display_notice( 'error', $result['error'] ); $result['error'] = ob_get_clean(); die ( json_encode( $result ) ); } $post_type_obj = get_post_type_object( $post->post_type ); $contact_form_verbiage = array( 'singular_name' => $post_type_obj->labels->singular_name, 'singular_name_lcase' => strtolower( $post_type_obj->labels->singular_name ), 'author' => __( 'Author', APP_TD ), ); $contact_form_verbiage = apply_filters('va_contact_form_verbiage', $contact_form_verbiage, $post ); $form_fields = array(); foreach( array( 'name', 'phone', 'message' ) as $form_field ) { // If we want to check for presence of the submitted fields, i.e. required fields, this would be where to grab it and die() the error. $form_fields[$form_field] = apply_filters('va_contact_form_fields', sanitize_text_field( $_POST[ 'contact_' . $form_field ] ), $form_field, $post_id ); } ob_start(); appthemes_load_template('email-contact.php', $form_fields ); $content = ob_get_clean(); if ( empty( $content ) ) { $content = html( 'p', sprintf( __( '%1$s %2$s Contact Form Submission:', APP_TD ), $contact_form_verbiage['singular_name'], $contact_form_verbiage['author'] ) ); $content .= html( 'p', sprintf( __('Someone is contacting you regarding your %s: %s', APP_TD ), $contact_form_verbiage['singular_name_lcase'], html_link( get_permalink( $post_id ), $post->post_title ) ) ); $content .= html( 'p', sprintf( __('Name: %s', APP_TD ), $form_fields['name'] ) ); $content .= html( 'p', sprintf( __('Phone: %s', APP_TD ), $form_fields['phone'] ) ); $content .= html( 'p', sprintf( __('Message: %s', APP_TD ), '<br />' . $form_fields['message'] ) ); } $recipient = get_user_by( 'id', $post->post_author ); $subject = sprintf( __('[%s] Contact Form Submission - %s', APP_TD ), get_bloginfo( 'name' ), $post->post_title ); va_send_email( $recipient->user_email, $subject, $content ); $result = __( 'Your message was sucessfully sent!' , APP_TD ); ob_start(); appthemes_display_notice( 'success', $result ); $result = ob_get_clean(); die ( json_encode( $result ) ); } function my_new_child_theme_setup() { remove_action( 'wp_ajax_va-contact', 'va_contact_form' ); remove_action( 'wp_ajax_nopriv_va-contact', 'va_contact_form' ); } add_action( 'after_setup_theme', 'my_new_child_theme_setup' ); add_action( 'wp_ajax_va-contact', 'my_new_contact_form' ); add_action( 'wp_ajax_nopriv_va-contact', 'my_new_contact_form' );
Shannon (August 5th, 2013)
psicologiavenezuela (August 15th, 2013)
There are currently 1 users browsing this thread. (0 members and 1 guests)