• Resolved falcobus

    (@falcobus)


    Hi Greg,

    I using contact form in ads.
    When I send answer from ads by contact form, I must fill name, email, subject and text.
    I would like hide input subject, and set automatic subject as ads title.
    I try snippet contact-form-email.php, but without changes.

    Can you help me?

    Thanks

Viewing 1 replies (of 1 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    to hide the subject field and set a predefined title you would need to add the code below in your theme functions.php file

    
    add_filter( "adverts_form_load", "remove_contact_form_subject" );
    function remove_contact_form_subject( $form ) {
      if( $form['name'] != "contact" ) {
        return $form;
      }
      foreach( $form["field"] as $key => $field ) {
        if( $field["name"] == "message_subject" ) {
            unset( $form["field"][$key] );
        }
      }
      return $form;
    }
    add_filter( "adverts_contact_form_email", "contact_form_email", 10, 3 );
    function contact_form_email( $mail, $post_id, $form ) {
        // get the post
        $post = get_post( $post_id );
        // Include Advert title in the subject
        $mail["subject"] = $post->post_title;
        return $mail;
    }
    
Viewing 1 replies (of 1 total)

The topic ‘Automatic subject in contact form’ is closed to new replies.