[Plugin: Contact Form 7] Any way to fetch a post title to a contact form? (12 posts)

  1. WhiteKnightProjects
    Posted 7 years ago #


    I woul dlike to use this plugin to receive 'quote requests' from people and would love a way to grab the wordpress post title and automatically add it to the contact form. Anyone know if this is possible?


  2. thelastknight
    Posted 7 years ago #

    If I remember right, Contact Form 7 has to be used in a post. So when the post containing the contact form is displayed (which will be single.php) just use <?php the_title(); ?>.

  3. WhiteKnightProjects
    Posted 7 years ago #

    Thanks for the idea but that's not quite the way I was hoping to get it to work - although I may have to resort to it.

    I'd like to be able to enter a 'quote me' button/image/link on every post and when users click it, they get taken to a generic 'quote page' (contact page) and then the contact form somehow prefills the post title from the referrer to the form, so that I know what quote my users are requesting...

    Do you have any workarounds along those lines?

  4. WhiteKnightProjects
    Posted 7 years ago #

    Ive been giving this some thought and I have managed to get to the stage where simply sending the post title in the form will be sufficient.

    So if there is a way to include <?php the_title(); ?> in the form somewhere then this will work.

    The objective is for the admin to receive the email from the site (via CF 7) but to know which product the user was requesting information on.

    I'd be grateful for any help.


  5. jaslr
    Posted 7 years ago #

    I too would like a response to this.

    I have built a website around WordPress and installed the Contact Form 7 at the base of each page (not post). I would like to know what page the user sent the enquiry from...

  6. gegenalles
    Posted 7 years ago #

    I'm also looking for a way to do this.

    But if you simply add "the_title()" to your e-mail, the email text would always be the title of your contact form - page, not the title of the referral post.

    My approach was to do it with a hidden field, that contains a php-variable:
    I've got one contact-form-page.
    I access it via "http://myblog.com/contact-form?myreferral=1".

    myreferral is the ID of the referral post.

    I've found a way to insert this variable as a hidden field into the contact form.

    But that hidden field is not mailed.

    		$form .= '<form action="' . $url . '" method="post" class="wpcf7-form"' . $enctype . '>';
            $form .= '<div style="display: none;">';
    		$form .= '<input type="hidden" name="_wpcf7" value="' . $id . '" />';
    		$form .= '<input type="hidden" name="_wpcf7_version" value="' . wpcf7_version() . '" />';
    		$form .= '<input type="hidden" name="_wpcf7_unit_tag" value="' . $unit_tag . '" />';
    		$form .= '<input type="hidden" name="interesting" value="' . $fcinteresting . '" />';

    This is where I inserted the hidden field "interesting".

    The field appears in the form markup, but it isn't included in the mail.

    Any idea ?

  7. jaslr
    Posted 7 years ago #

    I am still looking for a solution for this. I would love a checkbox inside the admin screens for Contact Form 7 that simply said, "Insert page ID as custom field".

    That would solve everything for me...

  8. WhiteKnightProjects
    Posted 7 years ago #

    I had to switch to cforms 10 to get the desired affect. It actually has a setting built in that allows you to include the post title in the subject line of the email.

    It was not ideal but it served my purpose.

  9. jaslr
    Posted 7 years ago #

    Any other solutions here? (Besides switching to cform)

  10. timoxxl
    Posted 7 years ago #

    i would be interested into this as well

  11. timoxxl
    Posted 7 years ago #

    hi Takayuki would be really great to get an reply on this.

    or just contact me on ICQ 463255313

  12. Screaminchief
    Posted 6 years ago #

    Hi guys

    This solved the problem for me!


    Good luck!

Topic Closed

This topic has been closed to new replies.

About this Topic