Wpcf7 Submission

Wpcf7 Submission




🛑 ALL INFORMATION CLICK HERE 👈🏻👈🏻👈🏻

































Wpcf7 Submission

Just another contact form plugin for WordPress. Simple but flexible.



Contact Form 7 5.5 is now available. The main feature is the introduction of the Stripe integration module that brings a simple payment widget to forms. 5.5 also includes some important security enhancements. In addition, a lot of bug-fixes and improvements have been done. Upgrading immediately is recommended.
The much-needed payment service joins the lineup of Contact Form 7’s officially supported integrations. The Stripe integration module allows you to add a credit-card payment widget into your contact forms in simple steps.
For details, see Stripe integration .
WPCF7_UPLOADS_TMP_DIR is a constant that is used to customize the temporary directory for uploaded files . As part of the security enhancement in 5.5, this constant changes to work only in cases where the value refers to a directory that is located under the WordPress content directory ( WP_CONTENT_DIR ). Otherwise, the constant will be ignored and the default directory path will be used.
There should be no necessity to have the directory for uploaded files outside the content directory that is under the control of WordPress. If you have an invalid setting in the constant, you should correct it as soon as possible.
Another security enhancement in 5.5 is to apply the KSES filter to the form template and the email body template. KSES is a set of PHP functions that strips disallowed HTML elements and attributes from the target content. Unless you are a privileged user who has the unfiltered_html capability, you are not allowed to use the disallowed HTML in the contact form editor screen.
Contact Form 7 defines its own list of allowed HTML elements and attributes. Although the list covers most elements and attributes that are often used for form controls, you can also customize it using the wpcf7_kses_allowed_html filter hook, if necessary.
Requires: WordPress 5.7 or higher
Tested up to: WordPress 5.8.1
You can browse the full list of changes on GitHub .
Contact Form 7 5.4 February 24, 2021 In "Releases"
Contact Form 7 5.5 October 11, 2021 In "Releases"
Contact Form 7 5.1 December 11, 2018 In "Releases"


By Rick Hellewell on July 24th, 2017 in PHP , WordPress
add_action( 'wpcf7_before_send_mail' , 'my_change_subject_mail' );

prop( 'mail' ) ;

$mail [ 'subject' ] = "this is an alternate subject" ;

Store our new subject back into the CF7 ContactForm object
// Save the email body
$WPCF7_ContactForm ->set_properties( array ( "mail" => $mail )) ;

Look at all the contents of the object
// error_log( print_r( $WPCF7_ContactForm, 1 ) );

add_action( 'wpcf7_before_send_mail' , 'my_change_subject_mail' );
function my_change_subject_mail( $WPCF7_ContactForm )
{
$wpcf7 = WPCF7_ContactForm :: get_current() ;
$submission = WPCF7_Submission :: get_instance() ;
if ( $submission )
{
$posted_data = $submission ->get_posted_data() ;
// nothing's here... do nothing...
if ( empty ( $posted_data ))
return ;
$subject = $posted_data [ 'your-message' ];
//$subject = substr($this->replace_tags( $template['subject'] ), 0, 50);
// do some replacements in the cf7 email body
$mail = $WPCF7_ContactForm ->prop( 'mail' ) ;
$mail [ 'subject' ] = "this is an alternate subject" ;
// Save the email body
$WPCF7_ContactForm ->set_properties( array ( "mail" => $mail )) ;
// error_log( print_r( $WPCF7_ContactForm, 1 ) );
// return current cf7 instance
return $WPCF7_ContactForm ;
}
}

Some notes about using (and perhaps abusing) the Contact Form 7 process in a WordPress site. (Contact Form 7 is a popular plugin for WordPress sites that lets you easily create a Contact Us type form. We use it here, although we’ve also tweaked what it does with our FormSpammerTrap for Contact Form 7 plugin that effectively reduces Contact Form spam. You can check out that plugin – and our other FormSpammerTrap spam-bot blocking techniques at our FormSpammerTrap.com site.)
We were inspired by an article we found via the googles while searching for information on CF7 hooks, because we wanted to do things to the CF7 form content after it was submitted, but before the form was emailed. The article is here . The code is theirs, but we wanted to explain it in more detail (mostly for our own purposes, as we wanted to use a similar process for our own purposes).
Let’s take a look at what we can do after the Contact form is submitted, and before CF7 emails the message. Our intent is to change the Subject line of the form to something other than what the visitor entered. You could easily use this code for your own purposes.
First, lets ‘hook’ into the wpcf7_before_send_mail process. This is done with the standard WP add_action function. (Remember that you can ‘hook’ into any WP function that has a ‘hook’. Ask the googles how the add_action thing works.) Here is the code that you would place in your Child Theme’s function.php file (or perhaps in a plugin):
This will wait for the hook to be called, and run the my_change_subject_mail() function.
Now we need to create the my_change_subject_mail function. I’m going to show and explain each line separately. We’ll put the entire function at the end.
This will get the current WPCF7_ContactForm object. We need this object to change the subject value therein.
Here we get the Submission object, which is generated when the user hits the ‘send’ submit button.
Next, let’s ensure that the contact form has been submitted.
If the form is empty, exit the function.
This is how we read a value of the form. The basic CF7 Contact Form has variables, this next line references the variable that was defined as ‘your-message’. If you want to work with another field on the form, use that field name as the parameter of the $posted_data array.
At this point, you could do a search/replace on the subject, or anything else. For instance, maybe you’d like to store the message fields in a database. You would set various variables – like we did with the $subject variable – to values from the $posted_data array. Then you could store those variables into a table in your database.
We’re not going to do anything with the $subject variable, we just wanted to show you that it could be done.
Our intent is to change the ‘subject’ of the email to something else. First, we have to read the property of the $mail object. This is the object that CF7 uses to create the email.
Since the subject line in our CF7 form is called ‘subject’, here is how we change the contents of that field:
Now that we have changed a value in the $mail array, we need to set that value in the WPCF7_ContactForm object:
If we are curious about all of the contents of the WPCF7_ContactForm object, we could quickly write it to the error.log file. This is OK for our purposes, as we are on a development site, and the error.log is a quick way to look at something. Note that you can’t ‘echo’ or ‘print’ anything to the screen in this process; it won’t be shown.
All done. We’ll return the object just in case it is needed.
By looking at the contents of the object, you might find other things that you might like to change. The $mail part of the object is stuff that will be emailed.
The result of all of this is that we have changed the subject line of the emailed message with out little function. We could add additional parts (maybe some extra data like the IP address of the sender, or whatever) to the $mail array -maybe the message content – and that would also be sent.
All done! Any questions, use the comments. We’ll try our best to muddle through an answer to your question.
I have a form and i need to change subject and add mail tags in capitalize letters ..
( sorry about my english im from southamerica )
Well I have the subject like this :
“Email Send from Website – [name] [othername] [phone]”
The problem that the email arrives the subject like this ..
“Email Send from Website – john luke 1832929923” ( this is just an example )
How can i make that the subject submit in upercase or capitalized??
Thanks for your comment.
Changing the subject (entered into the form) to uppercase is quite easy.
Change this line in the code (line 12)
$subject = $posted_data['your-message'];
to

$subject = strtoupper($posted_data['your-message']);
Now your subject text is all uppercase.
To get the subject to capitalize only the first letter of words, use this:
$subject = ucwords($posted_data[‘your-message’]);
What was the purpose of defining the following variable, if it wasn’t referenced anywhere after defining it. Or am I missing something?
$wpcf7 = WPCF7_ContactForm :: get_current() ;
That just gets the current Contact Form as an object, so I can do something before sending the mail.
Hi,
i’ve a question i have to change attached file to send to a user.
User change option radio field :
1) wine chart
2) menu
If user chooses wine chart i send pdf wine chart, if he chooses menu chart i send menu chat.
The field is radio field named scelta
[radio scelta use_label_element default:1 “Carta dei vini” “Menu”]
the two files are in these locations :
Hi, Nice Post
Based on your post, trying to accomplish this:
// do some replacements in the cf7 email body
$mail = $WPCF7_ContactForm->prop(‘mail’);
$mail[‘body’] = “CUSTOM 1” ;
// Save the email body
$WPCF7_ContactForm->set_properties( array(“mail” => $mail)) ;
// do some replacements in the cf7 email body
$mail_2 = $WPCF7_ContactForm->prop(‘mail_2’) ;
$mail_2[‘body’] = “MAIL_2” ;
// Save the email body
$WPCF7_ContactForm->set_properties( array(“mail” => $mail_2)) ;
to change the 2nd $WPCF7_ContactForm->set_properties(array(“mail” => $mail_2));
to
$WPCF7_ContactForm->set_properties(array(“mail_2” => $mail_2));
if i want to sent with post request all data to filezilla
$name = $posted_data[‘full_name’];
do this i already a post or should i put it in a $_POST???
It’s probably best to ask on the Contact Form 7 WP plugin support site: . My post is just an information source – mostly for me to remember how I did something.
Note that I am not a big fan of FileZilla – they store (or used to several years ago) FTP credentials plain text in a file on your computer. So I stopped using them and changed to WinSCP. They may have changed their policy, but when I asked them about it several years ago, they weren’t willing to plug what I thought was an obvious security hole. (Although physical possession of your device reduces your device’s security, but I didn’t like that policy.) See my post from way back in 2012: .
Hi, I already used your function to modify subject on the way but I could not modified a hidden field value too.
Also used an contact form redirection extension so it pass form values to another page via http query
The problem is I can get the hidden field value by $posted_data[‘hiddenfieldname’] but I cant set a new value to it: $posted_data[‘hiddenfieldname’] = “new value”
So after submit it redirects the page but not pass new value for hidden field.
It’s probably best to ask on the Contact Form 7 WP plugin support site: . My post is just an information source – mostly for me to remember how I did something.
Hi Rick,
I’d like to change the value of one specific field before sending (not the subject). How can I do that ?
Thanks
Jacques
We are glad you have chosen to leave a comment. Please keep in mind that comments are moderated according to our comment policy. Required fields are marked with a red asterisk ( * ).
Use the buttons to format your content. Use Shift+Ctrl+V to paste text. Use Ctrl+RightClick to see spelling suggestions. We suggest that you keep any fancy formatting to a minimum.
Please carefully review your comment before submitting.

Check out my fictional books at my author web site: RichardHellewell.com .


There are two classic westerns, a trilogy of an alternate worlds, an old technothriller, and more. All available - see the web site.


Mutiny Bay Publishing - our publishing company.

We have a great technique for stopping form spammers on your site - even for WordPress! It is quite simple to implement, and it is free!
Head on over to our Form Spammer Trap page for more details.
Did we mention that it is free? And very effective?

Check out all of our WordPress plugins at our main CellarWeb.com .


This site uses our CellarWeb Jason theme. Contact us for more information.

CellarWeb-Jason Theme, © Copyright 2020 - 2022 by Rick Hellewell / CellarWeb.com , All Rights Reserved.

Classe/tipologia: WPCF7_Submission
/**
* Set the notification email when sending an email.
*
* @since WP Job Manager - Contact Listing 1.0.0
*
* @return string The email to notify.
*/
public function notification_email($components, $cf7, $three = null)
{
$submission = WPCF7_Submission::get_instance();
$unit_tag = $submission->get_meta('unit_tag');
if (!preg_match('/^wpcf7-f(\\d+)-p(\\d+)-o(\\d+)$/', $unit_tag, $matches)) {
return $components;
}
$post_id = (int) $matches[2];
$object = get_post($post_id);
// Prevent issues when the form is not submitted via a listing/resume page
if (!isset($this->forms[$object->post_type])) {
return $components;
}
if (!array_search($cf7->id(), $this->forms[$object->post_type])) {
return $components;
}
// Bail if this is the second mail
if (isset($three) && 'mail_2' == $three->name()) {
return $components;
}
$recipient = $object->_application ? $object->_application : $object->_candidate_email;
//if we couldn't find the email by now, get it from the listing owner/author
if (empty($recipient)) {
//just get the email of the listing author
$owner_ID = $object->post_author;
//retrieve the owner user data to get the email
$owner_info = get_userdata($owner_ID);
if (false !== $owner_info) {
$recipient = $owner_info->user_email;
}
}
$components['recipient'] = $recipient;
return $components;
}
/**
* [nombre_del_formulario] [Esto ocupo para comparar el nombre del formulario para guardar en la tabla correcta]
*
* [nombre_de_la_tabla] [se concatena con el prefijo seleccionado en la instalacion que por defecto es wp_ + nombre de la tabla a guardar]
*
* [$submited['posted_data']['nombre_campo_form']] [Para jalar datos del formulario lo sacamos de un array $submited['posted_data'] seguido del nombre del campo ingresado en el form ['nombre_campo_form']]
*
* [save_form Guarda en base cualquier formulario enviado por contact form 7]
* @param [type] $wpcf7 [variable global de wp que se utiliza para guardar datos en esta funcion]
* @return [type] [description]
*/
function save_form($wpcf7)
{
global $wpdb;
/*
Note: since version 3.9 Contact Form 7 has removed $wpcf7->posted_data
and now we use an API to get the posted data.
*/
$submission = WPCF7_Submission::get_instance();
if ($submission) {
$submited = array();
$submited['title'] = $wpcf7->title();
$submited['posted_data'] = $submission->get_posted_data();
}
/**
* Uso de la mayoría de formularios acerca de suscribirse o no
*/
if ($submited['posted_data']['info'] == 'on') {
$info = 'Si quiero recibir informacion';
} else {
$info = 'No quiero recibir informacion';
}
if ($submited['title'] == 'nombre_del_formulario') {
$wpdb->insert($wpdb->prefix . 'nombre_de_la_tabla', array('nombre' => $submited['posted_data']['your-name'], 'apellido' => $submited['posted_data']['last-name'], 'email' => $submited['posted_data']['email-gana'], 'artista' => $submited['posted_data']['artist-fav'], 'info' => $info, 'fecha' => date('Y-m-d')));
}
}
function wpcf7_do_before_send($wpcf7)
{
$submission = WPCF7_Submission::get_instance();
$data = $submission->get_posted_data();
$_SESSION['posted_data'] = $data;
return true;
}
function beforeSendEmail($cf7)
{
$submission = WPCF7_Submission::get_instance();
if ($submission) {
$data = $submission->get_posted_data();
$dataArr = array_merge($data, array('created_date' => current_time('mysql')));
add_post_meta($data['_wpcf7'], 'cf7-adb-data', $dataArr);
}
}
function ip_wpcf7_mail_sent($wpcf7){
$submission = WPCF7_Submission::get_instance();
if ( $submission ) {
$formdata = $submission->get_posted_data();
$email = $formdata['your-email'];
$first_name = $formdata['your-first-name'];
$last_name = $formdata['your-last-name'];
$tel = $formdata['your-tel'];
$plan = $formdata['your-plan'];
}
$time = $today = date("F j, Y, g:i a");
// Open Agent:
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => 'http://ag.panda8.co/api?action=createAgentPph&creditAgent=1000&credit=100¤cy=USD&masterId=DEMVI&numOfUser=1&email='.$email.'&key=BBBAB3NzaC1yc2EAAAABJQAAAIEAhCdDMhGHdaw1uj9MH2xCB4jktwIgm4Al7S8rxvovMJBAuFKkMDd0vW5gpurUAB0PEPkxh6QFoBNazvio7Q03f90tSP9qpJMGwZid9hJEElplW8p43D3DdxXykLays2M8V2viYGLbiXvAbOECzwD4IaviOpylX0PaFznSR4ssXd0Int',
CURLOPT_USERAGENT => 'PPH186',
CURLOPT_FOLLOWLOCATION => 1,
));
$resp = curl_exec($curl);
$variables = json_decode($resp,true);
$agent = strtoupper($variables['agentId']);
$password = $variables['password'];
curl_close($curl);
// Send Info to bot
$text = urlencode("-- Sign up -- \n".$time."\n"."First Name: ".$first_name."\n"."Last Name: ".$last_name."\n"."Email: ".$email."\n"."Tel: ".$tel."\n"."Plan: ".$plan."\nAgent ID: ".$agent);
$curl = curl_init();
// Set some options - we are passing in a useragent too here
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => 'http://pph186.com/bot.php?key=b6fbc59dea1f5c41551f895886edbee5&msg='.$text.'&agent_id=sa',
CURLOPT_USERAGENT => 'PPH186'
));
// Send the request & save response to $resp
$resp = curl_exec($curl);
// Close request to clear up some resources
curl_close($curl);
$params = array(
"first_name" => $first_name,
"last_name" => $last_name,
"phone_mobile" => $tel,
"email1" => $email,
"account_name" => $agent,
"account_description" => $plan,
"campaign_id" => "c78e72d1-bfaa-b060-be8e-56cb258c33e6",
"assigned_user_id" => "1",
);
echo httpPost("http://crm.pph186.com/index.php?entryPoint=WebToLeadCapture",$params);
$_SESSION["first_name"] = $first_name;
$_SESSION["last_name"] = $last_name;
$_SESSION["account_name"] = $agent;


}
function action_wpcf7_mail_sent($contact_form)
{
$submission = WPCF7_Submission::get_insta
Slut Fists
Slut Wife Double
Anal Young Hardcore

Report Page