Hi jamminjames try the following URL. Let me know if this helps you.
After further searching, I found a post
here that seems to address the problem.
However, I tried it, and it’s not working for me. Does this only trigger when an email is sent? Because that’s the whole problem, no email is being sent, because the only way to send one currently is with all the data included, which I’m trying to avoid.
The function I added to my theme’s child functions.php file, basing it on the above link, is:
function my_process_fsctf_mail_sent($form) {
$all_forms = false;
$forms = array('2');
if ( !in_array($form->form_number, $forms) && $all_forms != true)
return;
foreach ($form->posted_data as $name => $value) {
$to = '[email protected]';
$subject = 'Registration Form submitted';
$message = 'A Registration Form has been submitted. Log in and click on Contact Form DB to see the database.';
wp_mail( $to, $subject, $message );
}
// do not return a string, because this is only an action hook
return;
}
// end function
// Hook into Fast Secure Contact Form after email sent
add_action('fsctf_mail_sent', array(&$this, 'my_process_fsctf_mail_sent'));
Is there something wrong with it? Thanks.
Just saw your link after I posted the above.
Question: Will using either the shortcode or function options shown there cause the entire email, with data, to be sent?
Hi in the URL you submitted above @mike Challis mentions the following
Instead of the foreach loop in the sample function, you can put code to send a WP mail
$to = ‘[email protected]’;
$subject = ‘test’;
$message = ‘test’;
wp_mail( $to, $subject, $message );
The URL I submitted above has a shortcode option you might like to consider.
For example, lets say that you don’t want to send a reply e-mail for a certain form but rather redirect the users to a custom reply page with some information. You have to disable the send any email option in the plugin.
I thought that meant to put the email code there. Are you saying I should change
foreach ($form->posted_data as $name => $value) {
$to = '[email protected]';
$subject = 'Registration Form submitted';
$message = 'A Registration Form has been submitted. Log in and click on Contact Form DB to see the database.';
wp_mail( $to, $subject, $message );
}
to just
$to = '[email protected]';
$subject = 'Registration Form submitted';
$message = 'A Registration Form has been submitted. Log in and click on Contact Form DB to see the database.';
wp_mail( $to, $subject, $message );
It looks to me like those shortcode options are just for sending the emails to certain addresses for certain forms, but that the emails sent would be the standard emails the plugin creates, which includes the data.
I’m trying to send JUST an email notification to the administrator (or whoever) that a form was filled out, but WITHOUT the data included in the form.
You might want to create a support ticket.
Regards
Okay, found a solution, using a hook in the CFDB (Contact Form Database) plugin.
For anyone else who wants to trigger an email notification, without the data, this is the code I added to my theme’s child function file. (Turn off the email Fast Secure Contact Form or Contact Form 7 sends to you when the form is submitted.)
<?php
// Send email when form submitted
function myFormFilter($formData){
$formName = 'Registration_Form'; // change this to your form's name
if ($formData && $formName == $formData->title) {
$to = '[email protected]';
$subject = 'Registration Form submitted';
$message = 'A Registration Form has been submitted. Log in and click on Contact Form DB to see the entry in the database.';
wp_mail( $to, $subject, $message );
}
return $formData;
}
add_filter('cfdb_form_data', 'myFormFilter');