pche32
Forum Replies Created
-
Forum: Plugins
In reply to: [Contact Form 7] hook into submit (client side) before executionErik you are GOLDEN!
thank you very much,since i fixed what you directed me to, it wasn’t even necessary change the way i registered javascript (so i left it using: wp_enqueue_script)
i’m posting code if anyone would be looking for something similar:
const wpcf7Forms = document.querySelectorAll('.wpcf7'); if (wpcf7Forms.length) { for (const wpcf7Form of wpcf7Forms) { const formElem = $(wpcf7Form)[0].querySelector('form'); let formData = new FormData(formElem.formData); function getArr() { //your logic here return arr; } formElem.addEventListener('formdata', (e) => { var arr = []; arr = getArr(); e.formData.append('custom-input', JSON.stringify(arr)); formData = e.formData; }); } }- This reply was modified 4 years, 10 months ago by pche32.
Forum: Plugins
In reply to: [Contact Form 7] hook into submit (client side) before executionHi Erik,
thank you very much for pointing me to the right direction,
if you don’t mind i would like to ask you additional/related question:since i prefer not to modify plugin’s script.js itself what is ideal place to hook my js (script in dedicated file) itself ?
and so if i understand it correctly, final code should look like this:
const formElem = $(wpcf7Form)[0].querySelector('form'); let formData = new FormData(formElem.formData); formElem.addEventListener('formdata', (e) => { e.formData.append('custom-input-field', JSON.stringify(arr)); formData = e.formData; });thank you very much for your support and patience
hello @ahmedkaludi,
because of this and other errors we decide to disable it for now,if you need any input regarding this error i reported, just let me know (what kind of data and how to gather them)
Regards
R