Wordpress Contact form 7: can I send 3 different emails? - wordpress

I have a contact form where people register his friend. The form sends the information to me and thank you email to user which register his friend , but I need send one more email to his friend with a different text . Is that possible with contact form 7 ?

Contact Form 7 has a wpcf7_mail_sent hook for this.
// ...in functions.php
add_action('wpcf7_mail_sent', function ($cf7) {
// Run code after the email has been sent
});

Since CF7 still doesn't do this itself, I wrote a basic plugin for it (More Mails for CF7). The crux of it is using CF7's hooks and functions to do most of the work for you:
Add another mail property (if it doesn't exist) with the filter hook wpcf7_contact_form_properties
Add another mail form section with the wpcf7_editor_panels filter hook.
Sanitise the incoming mail form data and assign it as a property of the form object in the wpcf7_save_contact_form action hook.
Allow it to be sent with the wpcf7_additional_mail filter hook.
It's not hard, each step is quite small. The relevant code is here, but you don't have to use any of the parts that create a settings page if you're happy setting a static number of extra mail messages in your code.

Related

How to programmatically change the default messages in Contact Form 7?

I am trying to edit the error message for spam in the contact-form-7 plugin in WordPress. As of now it only shows a simple message with 'there was an error trying to send your message', I would like to change this. But I can not figure out where to find the place in the code where this message is sent from. I have found the default message, but once this is changed, this does not do anything.
Where can I find this?
There are 2 ways to change the default messages in CF7, one is using the admin cf7 form editor which has a tab 'Messages', while the 2nd way is to hook the 'wpcf7_messages' filter fired by the plugin once all the messages have been set,
//give a prioity >10 to ensure you filter hooks after those of the plugin.
add_filter('wpcf7_messages', 'change_spam_filter', 20,1);
function change_spam_filter($msgs){
$msgs['spam']['default'] = "this is a custom spam message";
return $msgs;
}
this filter only fires on the admin back-end and not on the front-end. If you need to filter the message when the form is submitted you can hook,
add_filter('wpcf7_display_message','',10,2);
function filter_spam_msg($message, $status){
if('spam' != $status) return $message;
$message = "this is a custom spam message";
return $message;
}
EDIT: note that as of v5.5 of the CF7 plugin, HTML formatted responses can longer be diplayed on form submission. To do this you will need to install an extension. See this answer.

How to submit a Contact Form without sending email?

I have Contact Form 7 and Contact Form DB installed on my WordPress site, but don't and don't want to have a mail server. At this moment, I can collect form information from Contact Form DB, so is there any ways to disable the mailing function of a submit button?
Adding this into the Additional Settings section makes it stop mailing.
demo_mode: on
Add this code to your plugin or functions.php
add_filter('wpcf7_skip_mail', 'yourname_wpcf7_skip_mail');
function yourname_wpcf7_skip_mail()
{
return true;
}
It works for me.
There may have been some changes. For example, on current version setting demo_mode: on will result in database not being filled with forms.
Use skip_mail: on instead.
From the official website:
The skip_mail setting works in the almost same
manner as the demo_mode, but the skip_mail skips the mail sending
only. Unlike demo_mode, skip_mail doesn’t affect other activities like
storing messages with Flamingo.
Source:
https://contactform7.com/additional-settings/

Send thank you email in wordpress after user is redirected from other website

This is the problem I am trying to find a solution to: I manage a wordpress site that deals with donations. There are 5 options. Once the user clicks on one of them they are sent to a third party site to make a donation. After they make the donation they are redirected back to my site with a set of data (name, email etc.). What I need to do is get that data and send a thank you email to the user. Is there some wordpress plugin I can use to handle the incoming data and send the email? Or maybe use a plugin like Contact form 7 to do it? I am not really familliar with wordpress. Really basic knowledge
The easiest way to do this would be to create a custom page template with logic to capture the data sent after donating in it and apply the template to a page.
E.g.
wp-content/themes/your-theme/ipn.php
<?php
/**
* Template Name: IPN
*/
// Grab the data that's returned, however it's returned.
$data = $_GET['data'];
// Use WordPress mail function to send your email
wp_mail( $to, $subject, $message, $headers, $attachments );
// Either redirect to another page or display a thank you message.
Then go into your admin, create a new page called IPN, select your page template from the drop down and publish. You can use the URL to this page to pass data back to it from the 3rd party site after payment.

Wordpress Form Submit button GETS (or POSTS) form data to external page

We have a wordpress website that does marketing display, but now we want to allow a customer to submit an email and selection to a separate website with a landing page that will handle the backend DB work and finish them in the other website.
Something like,
www.ourmarket.com/getdata (on Submit button click GETS to...)
www.ouradminsite/landingpage.aspx (which processes the data that the use will not see then...)
www.ouradminsite/login.aspx (where the user can now login)
I am not familiar with WP at all, but I was able to create a page with a form that has the textbox/combobox I need.
I thought it would be something simple, but somehow it seems not. I read about AJAX and doing something in functions.php and creating a custom .js file, but when working on the marketing site I find no way to add this type of function in.
My fall back is to have the WP page just have a link to a generic landing page where they enter data, but it would be visually jarring to the customer unless I duplicate the WP site for one page.
Is there an easy way to just tell WP to redirect to an external page with a GET?
UPDATE--------------
I like to think I'm making progress. I found a link that may have given me a good start. I added a function to the functions.php file located in my WP theme. It starts like this:
add_action("gform_post_submission_4", "set_post_content", 10, 2);
function set_post_content($entry, $form){
//Gravity Forms has validated the data
//Our Custom Form Submitted via PHP will go here
// Lets get the IDs of the relevant fields and prepare an email message
$message = print_r($entry, true);
// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70);
// Send
mail('myuser#mycompany.com', 'Getting the Gravity Form Field IDs', $message);
**wp_redirect("http://my.hearbuilder.com/hellomoto.aspx",301);**
}
From there I tried to edit the function to do that wp_redirect, just a simple one to start. This is added under the mail statement:
wp_redirect("http://my.hearbuilder.com/hellomoto.aspx",301);
From this link, when I fill out the form I can get the email, but the new page did not display. I added the exit; line and still got the same result, the page seems like it hangs.
The end result is that I need to have the new website landing page display (after it processes the data from the Wordpress form.
What am I still missing?
yes use wp_redirect()
if($_POST):
$textbox=$_POST['textboxname'];
$url= 'url'.'?custom=hello&textbox='.$textbox.'&anothervalue='.$anothervalue;
wp_redirect($url);
exit;
endif;
you can easily add the variables to the string as needed. The easiest way to control the url properly is to post the information to the same page , catch the post and redirect (place before get_header call or any output has started)
The other way is php Curl which is more difficult esp when dealing with .asp pages, but if you have access to the other server it makes figuring it out easier!

Return a unique number to the customer after apply on our form (wordpress)

I'm making a web site with Wordpress, in which there is a form that has to be filled by customers. I want for every customer that will apply, after complete the filling and get the success message, to get via email a unique number and then contact with the company for the rest procedures. I'm also using contact-form-7 plugin for the form. Any idea or any plugin that could do this automatically? Even if code is needed, let me know!
Thanks in advance!
You could use the contact-form-7-dynamic-text-extension plugin.
Install the plugin, add
/* Generate Quote Ticket */
function genTicketString() {
return substr(md5(uniqid(mt_rand(), true)), 0, 8);
}
add_shortcode('quoteticket', 'genTicketString');
to your functions.php and add
Your Reference number: [dynamictext ticket "quoteticket"]
to your form in contact form 7. (or make this field invisible through css)
Lastly, add [ticket] to your e-mail body.
Found this solution on http://wordpress.org/support/topic/contact-form-7-generating-reference-number and was written by AMCD.

Resources