WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7
Integrating contact form 7 with custom search form for custom post type & fields (9 posts)

  1. Shashank Shekhar
    Member
    Posted 1 year ago #

    Hi,
    I am creating a search and listing website in wordpress. Have created some custom post type ex. 'Insurance' in wordpress with additional fields like 'name', 'email', 'dob', 'premium-amount',etc. Also, created contact form 7 having fields similar to what on that post type. This contact form okay displaying and working in frontend using its custom shortcode on a page.
    I need some way, so that a user/customer on my site fill his name, email, phone etc. along with search terms ('dob', 'premium-amount') in the contact form. These data should be mailed to admin email (as per contact7 form configuration in admin)and simultaneously the data filled should also be used to search results from 'Insurance' type and extra fields, make submit it go the search results page.

    The other way I can go through is, make a custom search form in frontend for it and on submitting go to search results page. But then it should be internally use the search fields data to post simultaneously to the contact form 7 so that the search field valus filled by customer can also be mailed to admin mail internally.

    I know how to create custom search form and also the contact form 7 override functions like wpcf7_before_send_mail, wpcf7_mail_sent, etc. but not getting the way to make a common form in frontend with multiple input fields to search the post type to display search results, and also mailing the input details to contact form 7 config mail. I dont need success or failure message of send mail to user. User just see the results page, but the query terms he searched for should be mailed internally.

    Please help me with that. And guide me which way should i think about: 1) putting contact form 7 form in frontend and using that to search results or, 2) putting custom search form in frontend and using that to mail using contact 7.
    (One common integrated form in frontend for both purpose.)
    and how?

    Thanks
    Shashank

    http://wordpress.org/extend/plugins/contact-form-7/

  2. Shashank Shekhar
    Member
    Posted 1 year ago #

    any reply plz? Does contact form 7 could have such extensibility or it not capable to extend it as required above?
    Please give me a hint support to proceed around...

  3. biswajeet
    Member
    Posted 1 year ago #

    Hi, Your requirement is way beyond for CF7 by out of the box. However, you can extend the CF7 features with additional modules but for a more robust solution, I recommend building your own custom plugin as per the requirement.

  4. Shashank Shekhar
    Member
    Posted 1 year ago #

    hahaha... but disappointed to see such reply. By the way, my so long detailed requirement info may look beyond scope, but in short, I just want to show a search form in frontend which normally go to search results page but simultaneously mail the customer's search's data/details filled in to admin email.
    Yes I am ready to write a plugin to connect contact form 7 with custom search form, but for that I need a hint a little bit idea to proceed for.
    Somehow, may I call the created contact form internally from theme/plugin files on search-form submit button to get the search field values in contact form fields and mail that.
    May be a little sample code help for normal search with single field can help me (no need for custom post search code). I will extend that if possible.
    Thanks for the response, but I hope someone, may be you can help me out. This is a normal functionality for business listing website to get what their users searching on their websites, so that they contact their customers as leads to their business.
    It will be great if such possibilities evolved using contact 7 as no other plugin I think directly giving this. May be my custom plugin will become an extension for contact 7 with your help.. :)

    Thanks,
    Shashank

  5. biswajeet
    Member
    Posted 1 year ago #

    Hi, the primary objectives of CF7 is to send emails and nothing else. So, I think there is no reason to get disappointed with your context...

    btw, with your requirement wouldn't be it nice to save the user searched data to directly DB rather than mailing each time a user search...? Later you can audit/browse all those data directly from dashboard.

    So, see possibilities are huge and I don't think you need CF7 for this purpose.

  6. karpediem
    Member
    Posted 1 year ago #

    @Shashank Shekhar => Did you find a solution to make what you wished ? it is exactly for what I try to make...
    Sorry for my bad english.

  7. Shashank Shekhar
    Member
    Posted 1 year ago #

    Hi karpediem, I have successfully made the custom search form page and search results page as per the wordpress custom search apis. But I spent many days for it on net and also own custom research.
    Have many links to implement custom search and queries, but mentioning few of them that can help you to start..
    http://codex.wordpress.org/Creating_a_Search_Page
    http://speckyboy.com/2010/09/19/10-useful-wordpress-search-code-snippets/
    http://fearlessflyer.com/2012/10/how-to-create-an-advanced-search-form-for-wordpress/
    http://ottopress.com/2010/wordpress-3-1-advanced-taxonomy-queries/
    http://stackoverflow.com/questions/12250957/wordpress-query-posts-taxonomy
    http://wordpress.stackexchange.com/questions/2117/query-posts-using-meta-compare-where-meta-value-is-smaller-or-greater-or-equ

    I had made a custom post type using 'Types' plugin having all the fields required to be searched with additional fields for more information. Then inside theme made a custom template need to render search form with custom input fields, and posted the form on a search-results page (a custom .php file inside my theme), which get those filled data, run custom queries to match those values for the custom fields in custom post type I made, and return results and finally display in custom html layout.

    The above links will help you to make custom form, result page and custom queries.

    The last thing now required is, when you press submit button on custom search form, you have to call 'contact-form-7' form also which can mail the data filled inside the form. (Also, by maintaining some hidden field or session or other additional checks we have to prevent mailing multiple times the same data if user press submit infinite times).

    This is the thing I have not made till now, because I am busy in other work not got proper time to do more research.
    But I hope from you, others and also from plugin authors to suggest us the way to call a contact-form-7 when a custom search form is filled and submit. Some actions, filters must exist in contact form 7 which we can call with custom data and post internally for mailing.

    In short I have completed other things successfully, just mailing is a thing we have to implement. If someone know please share, so all will be helped out, and reduce my further time for more research.

    --
    Thanks
    Shashank

  8. karpediem
    Member
    Posted 1 year ago #

    Thank you for all this information.
    I am going to study all this links and I shall return if I make something interesting.

  9. Himanshu Goel
    Member
    Posted 1 year ago #

    Hello - @ Shashank Shekhar

    Can You Provide that Version To Me (If It Generates The post Automatically After The Fill Up Of The Contact Form 7, The Only Thing Left By Me...)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic