Contact Form 7 Wordpress, checking a few fields, if empty then invalid

Could someone help me to solve the problem. I would like the system work like bellow. If both fields are empty = invalid. If any of the fields is completed = valid add_filter('wpcf7_validate_text', 'or_input_validation_filter', 20, 2); function or_input_validation_filter($result, $tag) { if ('your-link' == $tag->name) { $your_link = isset($_POST['your-link']) ? trim($_POST['your-link']) : ''; $your_file = isset($_FILES['your-file']) ? trim($_FILES['your-file']['name']) : ''; if($your_link == '' && $your_file == '') { $result->invalidate($tag, "One of the fields has not been completed?"); } } return $result; …
Category: Web

Contact form 7 send product PDF after submit

We are trying to display a cf7 form on woocommerce product pages, where users can submit the form and receive a pdf file related to the product (either as an email file attachment, as a link in the email body or even as a link that opens in a new browser tab). So far we have tried adding the pdf link as a product attribute and returning it with a shortcode, but... shortcodes don't work on CF7 e-mails. Does any …
Category: Web

Contact form 7 radio button default:get

I have three radio buttons and each should be selected according to which link the user click on some previous page [radio saletype use_label_element default:get "Commission sale" "Immediate sale" "Car exchange"] and /?saletype=2 dont work. Help please
Category: Web

How to access WC()->cart in CF7 hook wpcf7_special_mail_tags

I have created a page that allows users to request a quote based on Cart contents, in the wpcf7 hook wpcf7_special_mail_tags() I want to get the cart contents and return the output (cart items), but WC()->cart appears null in this hook, I cant work out how to get access to WC()->cart in this hook. The wpcf7_special_mail_tags() works fine and inserts other data into email, I just want cart data though. Thanks for any help.
Category: Web

How to disable reCaptcha v3 except on Contact Form 7 pages?

Contact form 7 is loading reCaptcha v3 scripts on all the pages of the sites which is making the website slow. So I was using the script below which was working fine before two weeks from now, but now it stopped working and it's now loading even more scripts. Why could it be? I don't want to use extra plugins. function contactform_dequeue_scripts() { $load_scripts = false; if( is_singular() ) { $post = get_post(); if( has_shortcode($post->post_content, 'contact-form-7') ) { $load_scripts = …
Category: Web

Issue with contact form 7

A client of mine has installed contact form 7 for their contact forms but they're getting an error in the From field "(configuration error) Invalid mailbox syntax is used." The form looks like this: [text text-54 placeholder "Your Name"][text text-54 placeholder "Your Company"] [email* email-317 placeholder "Email Address"][tel tel-646 placeholder "Phone Number"] [textarea textarea-820 class:large-input placeholder "Tell us about your requirements"] [submit "Request Callback"] Now in the from field in the mail section they had <[email your-email]> so I changed …
Category: Web

Contact Form 7 is not redirecting the "Thank-You" page with the removal of CSS and JS of plugins

I was working on on-site speed optimization. I removed the css and js files of the Contact Form 7 plugin. Through the following code in function.php function rjs_lwp_contactform_css_js() { global $post; if( is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, 'contact-form-7') ) { wp_enqueue_script('contact-form-7'); wp_enqueue_style('contact-form-7'); }else{ wp_dequeue_script( 'contact-form-7' ); wp_dequeue_style( 'contact-form-7' ); } } add_action( 'wp_enqueue_scripts', 'rjs_lwp_contactform_css_js'); As a result, I can't access the Thank you page. Mail goes correctly, but is not redirected to the "thank you page". Showing Error …
Category: Web

Show button once Contact form 7 is submitted

I would appreciate any help. I have set a contact form up and want to show a button to download a file once the form is submitted. This is showing all the time and should be hidden until the form is filled in. <div class="visible-only-if-sent"> <a href="demo.ogi.co.uk/download/1323" class="button big_large_full_width center default">Download CVM10-Lite </a> </div> But it is still showing on the page all the time. Can you please help me if I'm doing something wrong somewhere?
Category: Web

Contact Form 7 from adding paragraph and break tags to HTML emails

I'm trying to stop Contact From 7 from adding paragraph and break tags to HTML emails but can't figure it out. About 4 blank paragraph tags are added at the beginning of the email and two at the end. This question brings up the same issue, and the fix is said to have come in a recent update but I have the most recent one and no luck. Any ideas?
Category: Web

Contact7 Check Boxes line breaks when submitted

I am working on a wordpress Contact7 Form with a checkbox selection. I am wondering if there is a way when these checkboxes are submitted via email that the format is changed so instead of coming up item1, item2, item3 it comes up item1 item2 item3 I found this post, but the code does not seem to be working Add Line Break/Remove Commas for Checkbox options sent via Email from Contact Form 7 Its the exact same thin I am …
Category: Web

Email address used by website but I do not know where

I build a website for a client. This client then filled the website with content. I created 20 contact forms, using the contactform 7 and WP Mail SMTP Pro plugin. The website has now more than 100 pages. First my email address was used for the sites admin. I changed this later to my clients email address. I also used the client his email address for all of the contact forms. But now I still get a emails from the …
Category: Web

Conditional Logic on CF7 dropdown options

I need to create a form with two dropdowns ("Translate from" and "Translate to"), many options (Languages) inside on those dropdowns. If someone selects any language other than "English" the second dropdown should only have the option "English". How can I accomplish this? Thank you!
Category: Web

Copying uploaded images not working in wordpress

I am trying to copy an image uploaded using Contact Form 7 to the uploads directory but this only produces an empty jpeg file with 0644 permissions even though the dev directory and the uploads directory have 777 permissions while I try to solve the problem. I have had this particular set-up working, at least with the version of CF7 current in January 2017 but I cannot fathom why the copied images are always 0-byte files. The files are all …
Category: Web

Export Form Data to a CSV then send it as an attachment - contact form 7

I want to export the form data and send it as an attachment. In this case, can i rewrite the file (/uploads/2020/08/sample.csv) with the form data and send it as an attachment. right now, it is just a blank attachment when i receive it in my email Here is my code in function.php, Please help me: add_action( 'wpcf7_before_send_mail', 'add_form_as_attachment', 10, 1 ); function add_form_as_attachment(&$WPCF7_ContactForm) { $contact_form = WPCF7_ContactForm::get_current(); $Fname = $formdata['firstName']; $Lname = $formdata['lastName']; $email = $formdata['email']; $list = array …
Category: Web

Trying to update repeater field (ACF) dynamically with data from Contact Forms 7

I'm trying to feed a repeater field with the values submitted via a registration form (I'm using Contact Forms 7). When debugging the array of values passed to the "add_row" function, everything seems to be well introduced, but there must be an error because nothing happens, and the repeater is not updated. Actually, the function add_row seems to return false, but I cannot find the error... So far this is the code that I'm using: add_action( 'wpcf7_before_send_mail', 'mafsuf_wpcf7_update_repeater_field' ); function …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.