Support » Plugin: WPAdverts - Classifieds Plugin » Send Message Form Default Subject

  • Resolved Dmitry

    (@jack3000)


    Great plugin! One minor thing is that for the “Send Message” I recommend removing the subject field and automatically setting the subject to something like “Regarding Your Listing on [site_name], [page_title]” or similar. This would reduce the form and make it easier for people.

    Perhaps for the next update?

Viewing 13 replies - 1 through 13 (of 13 total)
  • Excellent idea!

    Plugin Author Greg Winiarski

    (@gwin)

    Hi, with some custom programming you can customize the title of the email sent using contact form, see https://github.com/simpliko/wpadverts-snippets/blob/master/contact-form-email/contact-form-email.php

    For example the code below will send the email with title “Regarding Your Listing on [site_name], [page_title]”

    
    add_filter( "adverts_contact_form_email", "contact_form_email", 10, 3 );
    function contact_form_email( $mail, $post_id, $form ) {
        $post = get_post( $post_id );
        $mail["subject"] = sprintf("Regarding Your Listing on %s - %s", get_bloginfo( "name" ), $post->post_title );
        return $mail;
    }
    
    Thread Starter Dmitry

    (@jack3000)

    Awesome! Thank you. I have included it using the Code Snippets plugin which I use for stuff like this. Worked perfectly. Now I can tweak it as much as I like.

    Thread Starter Dmitry

    (@jack3000)

    …is there a similar way to remove the Subject field from the contact form as it’s now not needed?

    Plugin Author Greg Winiarski

    (@gwin)

    You can use adverts_form_load filter to do that

    
    add_filter( "adverts_form_load", "customize_adverts_add" );
    function customize_adverts_add( $form ) {
      if( $form['name'] != "contact" ) {
        return $form;
      }
      foreach( $form["field"] as $key => $field ) {
        if( $field["name"] == "message_subject" ) {
            unset( $form["field"][$key] );
        }
      }
      return $form;
    }
    

    I am trying to edit>

        $mail["subject"] = sprintf("Regarding Your Listing on %s - %s", get_bloginfo( "name" ), $post->post_title );
    

    Would like it to state:

    Someone is Interested in Your Listing on WEBSITE

    Then the link and listing inside the email body.

    Thread Starter Dmitry

    (@jack3000)

    Works perfectly! Thank you.

    Plugin Author Greg Winiarski

    (@gwin)

    @gstar your code should be something like this

    
    $mail["subject"] = sprintf("Someone is Interested in Your Listing on %s", get_bloginfo( "name" ) );
    $mail["message"] = get_permalink( $post->ID ); 
    

    This will display link in the email body i am not sure what do you mean by “listing”.

    Excellent it includes the link but removes the message.

    What I was thinking of is having the email body say:

    MESSAGE FROM SENDER

    Your Listing: URL

    Plugin Author Greg Winiarski

    (@gwin)

    Change

    
    $mail["message"] = get_permalink( $post->ID ); 
    

    to

    
    $mail["message"].= "\r\nYour Listing URL " . get_permalink( $post->ID ); 
    

    Fantastic! How can I add a line break between the two?

    Plugin Author Greg Winiarski

    (@gwin)

    The “\r\n” adds a line break.

    Thanks!

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Send Message Form Default Subject’ is closed to new replies.