Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Contact form 7 set field value with get request

I want to set a field value with get request

example.com/subscribe/?email=asfafs

but when i load the page which has the form on it, the form does not show. I get why it could not be showing. Because the form itself could submit a get request as well. I also installed this plugin which should enable me to set a field value, but it does not.

this is what i have:

<p>Uw naam (verplicht)<br />
    [text* input-name] </p>

<p>Uw email (verplicht)<br />
    [dynamictext dynamicname "CF7_GET key='email'"] </p>
<p>Onderwerp<br />
    [text your-subject] </p>

<p>Uw bericht<br />
    [textarea your-message] </p>

<p>[submit "Verzenden"]</p>

In my page:

<?php echo do_shortcode('[contact-form-7 id="1062" title="Contactformulier 1"]'); ?>

I wouldn't mind using a different plugin for this. If there is one which suits my needs please tell me.

like image 638
Meneer Venus Avatar asked Jun 05 '14 12:06

Meneer Venus


People also ask

How do you set a field in Contact form 7?

Text field# Both text and text* are used for single-line input and accept any form of text. The difference between them is that text* connotes a required field. In Contact Form 7's convention, all types of tags with an asterisk '*' mean that these are required fields.

How can I get Contact form 7 value?

It is, however, possible to get the default values from the context within which the form is placed. To do this, add default:{source} option to the form-tag from which you want to derive the default value. Available data sources are: get (HTTP GET variables), post (HTTP POST variables), and post_meta (custom fields).

How do I change the default value in Contact form 7?

The simplest way of getting default values to your form is getting them from the post meta. There are no conditions to this and you simply set a default value for a form field. To do this, use the default keyword and set the desired default value.


1 Answers

I just installed the plugin you linked and tested it. The plugin isn't meant to pull in a GET variable for a field within Contact Form 7. The plugin will do two things

  1. It will grab the $_GET variable and create a hidden field with it.
  2. It will show the variable on the page (just as text, not in a field)

The shortcode that you have in your example is for use by this http://wordpress.org/plugins/contact-form-7-dynamic-text-extension/ plugin. I downloaded and tested that plugin as well, and it seems to work just fine.

Here is the page I created the example on. http://jtwebb.com/stackoverflow-question/?someemail=asdf if you want to take a look to see it is working with the dynamic-text-extension plugin.

UPDATE: This is my contact form 7 code:

<p>Your Name (required)<br />
    [text* your-name] </p>

<p>[showparam someemail] <-- this is the shortcode of show param, just text no field</p>

<p>[getparam someemail] If you inspect this you'll see a hidden get field with the value of 'someemail' in it.</p>

<p>Your Email (required)<br />
    [dynamictext* dynamictext-380 "CF7_GET key='someemail'"]<br>This field was created with <a href="http://wordpress.org/plugins/contact-form-7-dynamic-text-extension/">http://wordpress.org/plugins/contact-form-7-dynamic-text-extension/</a></p>

<p>Subject<br />
    [text your-subject] </p>

<p>Your Message<br />
    [textarea your-message] </p>

<p>[submit "Send"]</p>
like image 112
john Avatar answered Sep 21 '22 15:09

john