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?
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.
@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
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?
The “\r\n” adds a line break.