Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: How to modify the contact listing owner form

  1. #1
    Thread Starter
    red20me's Avatar
    Join Date
    Jul 2013
    Location
    United Kingdom
    Posts
    473
    Thanks
    1
    Thanked 104 Times in 93 Posts

    How to modify the contact listing owner form

    Hi,

    I want to amend the contact listing owner form in Vantage. This is built in function va_contact_form which is in custom-post-type-helper.php.

    The change I want to make is to remove the 'website' field, since (as discussed elsewhere in these forums), this is not really a useful field on the contact listing owner form.

    I have tried to override the va_contact_form function inside my child theme's functions.php, but I can't get it to work. Please could someone explain what I am doing wrong, or explain an alternative means of getting rid of the website field on this form?

    Here's the code that I added to my child theme functions.php:

    Code:
    // 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' );

    On a separate note, it would be really useful if you could restrict a forum search here at appthemes.com to just the forums for a specific theme....I have tried hard to find my own solution to the above, but I have to wade through endless posts about classipress etc., when I am only interested in Vantage solutions...am I missing something, does that facility already exist?

  2. #2
    Expired Customer hopfoto's Avatar
    Join Date
    Oct 2012
    Location
    NYC
    Posts
    954
    Thanks
    37
    Thanked 125 Times in 118 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!
    Running Vantage on 2 sites- both are on
    the Latest Development Build (1.2.2 dev)
    & WordPress 3.5.1

  3. The Following User Says Thank You to hopfoto For This Useful Post:

    Shannon (August 5th, 2013)

  4. #3
    Thread Starter
    red20me's Avatar
    Join Date
    Jul 2013
    Location
    United Kingdom
    Posts
    473
    Thanks
    1
    Thanked 104 Times in 93 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  5. #4
    Shannon's Avatar
    Join Date
    Mar 2011
    Location
    United States
    Posts
    577
    Thanks
    49
    Thanked 248 Times in 114 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  6. #5
    dimitris's Avatar
    Join Date
    Oct 2011
    Location
    Earth
    Posts
    20,617
    Thanks
    222
    Thanked 1,873 Times in 1,770 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  7. #6
    Expired Customer psicologiavenezuela's Avatar
    Join Date
    Jul 2013
    Location
    Venezuela
    Posts
    18
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Costum form

    You must be an AppThemes customer and logged in to view this response. Join today!

  8. #7
    dimitris's Avatar
    Join Date
    Oct 2011
    Location
    Earth
    Posts
    20,617
    Thanks
    222
    Thanked 1,873 Times in 1,770 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  9. The Following User Says Thank You to dimitris For This Useful Post:

    psicologiavenezuela (August 15th, 2013)

  10. #8
    Thread Starter
    red20me's Avatar
    Join Date
    Jul 2013
    Location
    United Kingdom
    Posts
    473
    Thanks
    1
    Thanked 104 Times in 93 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  11. #9
    dimitris's Avatar
    Join Date
    Oct 2011
    Location
    Earth
    Posts
    20,617
    Thanks
    222
    Thanked 1,873 Times in 1,770 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  12. #10
    tradeamillion's Avatar
    Join Date
    Mar 2012
    Location
    New York
    Posts
    1,076
    Thanks
    82
    Thanked 12 Times in 12 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!
    Computers are incredibly fast, accurate, and stupid: humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination.

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Which file edits "listing detail on category page" and "Contact owner form FIELDS"
    By doktorek in forum Vantage General Discussion (Legacy)
    Replies: 1
    Last Post: February 22nd, 2014, 07:52 PM
  2. Dimitris Edit Contact Listing Owner button and form
    By peterd in forum Help Using Vantage (Legacy)
    Replies: 4
    Last Post: May 29th, 2013, 09:48 AM