Frage

Ich möchte einen Feldwert mit der Anforderung erhalten

Beispiel.com/subscribe/?email=asfafs

Wenn ich jedoch die Seite lade, die das Formular darauf hat, wird das Formular nicht angezeigt.Ich verstehe, warum es nicht zeigen konnte.Weil das Formular selbst auch eine Get-Anfrage einreichen könnte.Ich habe auch installiert dies Plugin, das mir ermöglicht, einen Feldwert festzulegen, aber es nicht.

Das habe ich:

generasacodicetagpre.

auf meiner Seite:

generasacodicetagpre.

Ich hätte nichts dagegen, ein anderes Plugin dafür zu verwenden.Wenn es einen gibt, der zu meinen Bedürfnissen passt, sagen Sie mir bitte.

War es hilfreich?

Lösung

Ich habe gerade das Plugin installiert, das Sie verknüpft und getestet haben. Das Plugin soll nicht in einer Get-Variablen für ein Feld innerhalb des Kontaktformulars angezeigt werden. 7. Das Plugin wird zwei Dinge tun

    .
  1. Es wird die $ _get-Variable ergänzen und ein verborgenes Feld mit ihm erstellen.
  2. Es zeigt die Variable auf der Seite (nur als Text, nicht in einem Feld)
  3. Der Kurzcode, den Sie in Ihrem Beispiel haben, dient dazu dabei http://wordpress.org/plugins/contact-form-7-dynamic-text-extesion/ Plugin. Ich habe dieses Plugin auch heruntergeladen und getestet, und es scheint gut zu funktionieren.

    Hier ist die Seite, die ich das Beispiel eingeschaltet habe. http://jtwebb.com/stackoverflow-question/?someemail=asdf , wenn Sie Ich möchte einen Blick darauf werfen, um zu sehen, dass es mit dem Dynamic-Text-Extension-Plugin arbeitet.

    update : Dies ist mein Kontaktformular 7-Code:

    generasacodicetagpre.

Andere Tipps

[text* your-name default:get] The field will obtain its default value from the GET variable with the same name (“your-name”). Try this by accessing the URL of the page of the form with an additional query string:

http://example.com/contact/?your-name=John+Smith

But what if you have two or more default options in a single form-tag? Let’s consider this form-tag’s case:

[text* your-name default:get default:post_meta "Your Name"]

I know this question has already been answered but for anyone looking for a solution which doesn't require a plugin I opted to do the following.

First I created my form from within the plugin via the Wordpress dashboard. I added the field I wanted to hold the parameter from URL and assigned it an ID.

[text page-name class:form-control id:source minlength:2 maxlength:80]

Next I added a link which would pass the parameter to the form like so

<a href='http://mycoolwebsite.com/contact?id=homepage'>Contact Us</a>

Then using some Javascript and JQuery I get the id parameter from the URL and set it as the value for my input in the form. (The getParameterByName(name,url) function was taken from this answer: How can I get query string values in JavaScript?)

function getParameterByName(name, url) {
    if (!url) url = window.location.href;
    url = url.toLowerCase(); 
    name = name.replace(/[\[\]]/g, "\\$&");
    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
        results = regex.exec(url);
    if (!results) return null;
    if (!results[2]) return '';
    return decodeURIComponent(results[2].replace(/\+/g, " "));
}
var param = getParameterByName('id');
jQuery('#source').hide();
jQuery('#source').prop('disabled', true);
jQuery('#source').attr('value', param);
jQuery('#source').val(param);

I also hide and disable the input field so it is not seen and cannot be modified (easily). I also hide the input field using CSS

#source{visibility:hidden}

This way I can link to the form from any where within my site and append the source of where the person came from and place it in the email that I get.

I don't see any problems with this method and it removes the need to use a plugin. I'm sure it's not ideal to depend on Javascript but equally it's not ideal to use to many plugins on your site as they can become outdated very quickly and often can cause conflicts between one another.

Hope this helps anyone looking for an alternative. I'd like to know peoples opinions on this way as I'm open to suggestions on how to improve it.

You can initially in the form field set a unique text, and then use the hook to replace it with the desired value. And then no plugin will be needed.

Example. In form code:

<p>Phone<br />
[text phone "PHONE_VALUE"] </p>

in functions.php:

add_filter( 'wpcf7_form_elements', function( $form ) {
  $form = str_replace( 'PHONE_VALUE', $_GET['phone'], $form );
  return $form;
} );

in URL:

example.com/page?phone=111111

as per this article

if you want to send a value to a select list, this can be done easily by adding the parameter default:get to the field code:

[select* the-recipient default:get "Employee One|employeeone@yourdomain.com" "Employee Two|employeetwo@yourdomain.com" "Employee Three|employeethree@yourdomain.com"]

and then send the parameter in the GET request, like:

http://yourdomain.com/contact/?the-recipient=Employee%20Two
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top