Formulaire de contact 7 - Exécuter le code APRÈS l'envoi du courrier
-
-
Vousne pouvezpas utiliser lesparamètres supplémentaires dans lesparamètres duplug-in duformulaire de contact?- http://contactform7.com/additional-settings/Can't you use the additional settings in the contact form plugin settings? - http://contactform7.com/additional-settings/
- 0
- 2015-07-30
- Andy
-
Je lisaisjuste à ce sujetpendant queje suis sur Google,maisje ne saispas où sont cesparamètres.Celapermet-il cependant de rediriger un certainformulaire?J'aijustebesoin d'unformulaire spécifiquepour être redirigé,pastous lesformulaires.I was just reading about that as i'm Googling, but i don't where those settings are. Does this allow to redirect a certain form though? I just need 1 specific form to be redirected, not all forms.
- 0
- 2015-07-30
- Menno van der Krift
-
Peut-êtrepourriez-vous appliquer [cetype d'approche] (http://wordpress.stackexchange.com/questions/190928/do-something-after-sending-email)?Maybe you could apply [this kind of approach](http://wordpress.stackexchange.com/questions/190928/do-something-after-sending-email) ?
- 0
- 2015-07-30
- birgire
-
Ahh vient de letrouveret fonctionne comme un charme: D Mon Wordpressesten néerlandais,c'estpourquoije n'aipasputrouver les champs supplémentaires aussifacilement xDAhh just found it and works like a charm :D My Wordpress is in Dutch, hence why i couldn't find the Additional Fields that easily xD
- 0
- 2015-07-30
- Menno van der Krift
-
3 réponses
- votes
-
- 2015-07-30
MODIFIER:
Veuilleznoter que depuis 2017, 'on_sent_ok'est obsolète . Cela signifie que votre code cessera defonctionner à unmoment donné dans lefutur (probablement d'ici lafin de 2017). La solution recommandée consiste à utiliser directement les écouteurs d'événements DOM. Parexemple,si vous avez utilisé:
on_sent_ok: "ga( 'send', 'event', 'Contact Form', 'submit' );"
Vous devriez le remplacerpar:
document.addEventListener( 'wpcf7mailsent', function( event ) { ga( 'send', 'event', 'Contact Form', 'submit' ); }, false );
Le code JavaScriptpeut êtreplacéparex. dans lepied depage de votrepage.
RÉPONSE ORIGINALE:
OK,j'ai compris. Dans lesparamètres deformulaire spécifiques,accédez à l'onglet Champs supplémentaires. Tapez ce qui suit:
on_sent_ok: "location.replace('http://www.website-redirect.com');"
Celafonctionne comme un charmepourmoimaintenant. J'espère que cela aidera également d'autres développeurs à l'avenir.
Je sais que l'imageesten néerlandais ...mais vousne pouvezpas la rater avec les grandes lignes rouges autour dunom de l'onglet.
EDIT:
Please note that as of 2017 'on_sent_ok' is deprecated. This means that your code will stop working at some point in the future (likely by the end of 2017). The recommended solution is using DOM event listeners directly. For example, if you used:
on_sent_ok: "ga( 'send', 'event', 'Contact Form', 'submit' );"
You should replace it with:
document.addEventListener( 'wpcf7mailsent', function( event ) { ga( 'send', 'event', 'Contact Form', 'submit' ); }, false );
The JavaScript code can be placed e.g. in the footer of your page.
ORIGINAL ANSWER:
Ok figured it out. In the specific form settings, go to the additional fields tab. Type in the following:
on_sent_ok: "location.replace('http://www.website-redirect.com');"
It's working like a charm for me now. Hope this helps other developers in the future as well.
I know the image is in Dutch ... but you can't miss it with the big red lines around the tab name.
-
commentenregistrons-nous les cookiesen utilisant l'onglet supplémentaire?J'essaye ceci `on_submit:" ooid=document.getElementById ('customer_orderid'). Value; document.cookie='myorderiiid=' + ooid + ';expires=Thu,18 Dec 2025 12:00:00 UTC;path=/'; ";`mais aucun cookieenregistré .. POURQUOI?how we save cookie using Additional Tab? I try this `on_submit: "ooid = document.getElementById('customer_orderid').value;document.cookie = 'myorderiiid='+ooid+'; expires=Thu, 18 Dec 2025 12:00:00 UTC; path=/';";` but no cookie saved.. WHY?
- 0
- 2017-04-13
- Mostafa
-
Veuilleznoter que c'était une question d'il y a DEUX ANS ...Please note that this was a question from TWO YEARS ago ...
- 0
- 2017-10-30
- Menno van der Krift
-
Désolée,je n'avaispas assez de réputationpour l'ajouteren tant que commentaire à cemoment-là,donc la seulefaçon d'inclure cetteinformation était de lamodifier.Sorry, I didn't have enough reputation to add it as a comment at that time, so the only way to include this info was through edit.
- 0
- 2018-02-23
- Amade
-
- 2017-01-05
Pour quiconque atterritencoreici à la recherche d'unmoyen d'exécuter du code PHP après l'envoi de l'e-mail,Contact Form 7 a un hook
wpcf7_mail_sent
pourexactement cela.L'utilisation ressemble unpeu à:// ...in functions.php add_action('wpcf7_mail_sent', function ($cf7) { // Run code after the email has been sent });
Ilexiste également
wpcf7_mail_failed
,qui vouspermet de vous connecter lorsque l'e-mail échoue.For anybody still landing here looking for a way to run some PHP code after the email has been sent, Contact Form 7 has a
wpcf7_mail_sent
hook for exactly this. Usage looks a little like:// ...in functions.php add_action('wpcf7_mail_sent', function ($cf7) { // Run code after the email has been sent });
There is also
wpcf7_mail_failed
, which lets you hook into when the email fails.-
Celan'apasfonctionnépourmoi.Didn't work for me.
- 1
- 2017-03-01
- Pons
-
Quelle version de CF7 utilisez-vous?Celafonctionneen utilisant la version 4.6.1 avec WordPress 4.7.2Which version of CF7 are you using? I have this working using version 4.6.1 with WordPress 4.7.2
- 0
- 2017-03-02
- adamtomat
-
Jepense avoirtrouvé l'erreur dansmon code:j'aiencapsulémon appel add_action avec une vérification has_action.Maisprobablement lorsquemon code (à l'intérieur d'unplugin)estexécuté,l'action wpcf7_mail_sentn'existepasencore.Supprimez la vérification has_actionpour que celafonctionne.I think I've found the error in my code: I've wrapped my add_action call with a has_action check. But probably when my code (inside a plugin) is executed, the wpcf7_mail_sent action doesn't exist yet. Remove the has_action check made it work.
- 0
- 2017-03-03
- Pons
-
Quelest ceparamètre ($ cf7)?ai-jebesoin de çaWhat is this ($cf7) parameter? do i need this
- 0
- 2017-03-15
- Kevin.a
-
C'est uneinstance de `WPCF7_ContactForm`,qui contient untas d'informations sur leformulaire qui a été soumis. Parexemple,vouspouvez obtenir l'identifiant duformulaire avec `$ cf7->id ()`.Vousn'en aurezpeut-êtrepasbesoin,auquel cas vouspouvez le laisser de côtéjusqu'à ce que lebesoin sefasse sentir. Voici un lien vers la classe dans GitHub dans le cas où vous vouliezfeuilleter ce qu'ellefait: https://github.com/wp-plugins/contact-form-7/blob/master/includes/contact-form.phpIt's an instance of `WPCF7_ContactForm`, which contains a bunch of information about the form that was submitted. For example, you could get the id of the form with `$cf7->id()`. You may not need it, in which case you can leave it off until the need arises. Here's a link to the class in GitHub incase you wanted to flick through what it does: https://github.com/wp-plugins/contact-form-7/blob/master/includes/contact-form.php
- 0
- 2017-03-16
- adamtomat
-
- 2015-08-01
L'utilisation de on_sent_ok commeexpliqué sur contactform7.com/additional-settings peut êtretrès utilepouren ajouterJavaScript simple comme redirection vers une autrepage .
Cependant,ilestplutôt susceptible d'échoueren raison de conflits Javascript avec votrethème WordPress actuel ou l'un des autresplugins que vous utilisez.
on_sent_okest la dernière chose qui s'exécute dans leformulaire de contact 7,donctout conflit Javascriptinterférantpeut arrêter cette opération.
Enguise d'alternative,Contact Form 7 a ungrandnombre de hooks qui sont répertoriés sur http://hookr.io/plugins/contact-form-7/.Ceux-cipeuventfournir une solutionmieux cibléeet plus robuste.
Using on_sent_ok as explained at contactform7.com/additional-settings can be very useful for adding some simple JavaScript like redirecting to another page.
However it is rather prone to failing due to Javascript conflicts with either your current WordPress theme or one of the other plugins you are using.
on_sent_ok is the absolutely last thing that runs in Contact Form 7, so any interferring Javascript Conflict can stop this completing.
As an alternative, Contact Form 7 has a large number of hooks which are listed at http://hookr.io/plugins/contact-form-7/. These can provide a better targeted, more robust solution.
J'aitrouvé commentfaire quelque chose AVANT d'envoyer lemail,maisj'ai aussibesoin d'une action APRÈS sonenvoi.
J'aiessayé
wpcf7_after_send_mail
mais sans succès ...Toute aideen lamatière seraittrès appréciée.