Showing posts with label contact form 7. Show all posts
Showing posts with label contact form 7. Show all posts

Thursday, March 9, 2017

I see a response message “Your message was sent successfully” with green border, but I never receive a mail for that.

Recently i face this problem. Contact form display successful message sent. But mail is not recieved. All settings are perfect.

After this i installed one plugin. Easy WP SMTP.  Download here
Configure it with server. Set smtp and port. After this contact form perfectly working. 


You can also testmail also. Here is the setting for testing your settings are right or not.

 

Wednesday, March 1, 2017

add post or custom post title in contact form 7

Hello
I am trying to:
load all my post titles of a specific custom post type into a select box of my contact form.
Currently, I'm using Contact Form 7

Here is the solution :
You need to create a custom shortcode in the contact form 7 for the select box. In order to create the custom shortcode for displaying title in select box, you can use the following custom shortcode.

Add this code to your function.php file.

add_action( 'wpcf7_init', 'custom_views_post_title' );
  
function custom_views_post_title() {
    wpcf7_add_shortcode( 'custom_views_post_title', 'custom_views_post_title_shortcode_handler' );
}
  
function custom_views_post_title_shortcode_handler( $tag ) {
    global $post;
    $args = array( 'post_type' => 'event' );
    $myposts = get_posts( $args );
    $output = '<select name="eventname" id="fleet" onchange="document.getElementById(\'fleet\').value=this.value;"><option></option>';
    foreach ( $myposts as $post ) : setup_postdata($post);
       $title = get_the_title();
       $output .= '<option value="'. $title .'">'. $title .' </option>';
    endforeach;
    $output .= "</select>";
    return $output;
}
and use the shortcode [custom_views_post_title] in contact form 7.
Now how to display in contact form 7 email :
Your code is :
$output = '<select name="eventname">
So write  [eventname]