Shvakovski
Member
Posted 5 months ago #
Hi there.
I'm using wpcf7_before_send_mail hook to make a post with form fields. I also use CAPCTHA (default) at form.
I noticed that if I use wpcf7_before_send_mail hook and provide wrong CAPTCHA post is created anyway.
Couldn't find any documents with all CF7 hooks available. Maybe there are some wpcf7_AFTER_send_mail? How do I make some actions using "before send" hook only if CAPTCHA is accepted?
http://wordpress.org/extend/plugins/contact-form-7/
What CAPTCHA do you use and how do you use it?
Shvakovski
Member
Posted 5 months ago #
Hi, Takayuki. First of all, thanks for the great plugin.
I use CAPTCHA from CF7 admin (it asked to install Really Simple Captcha). At my form I output it like:
<p>Numbers<br />[captchac captcha-556][captchar captcha-556] </p>
And my code in functions.php:
function my_wpcf7_save($cfdata) {
$formdata = $cfdata->posted_data;
$newpost = array(...);
$newpostid = wp_insert_post($newpost);
}
add_action('wpcf7_before_send_mail', 'my_wpcf7_save',1);
If I enter wrong numbers I'm given an error but post is created. So I have as many posts created, as many times person/spambot tries to submit form.
If CAPTCHA validation get failed wpcf7_before_send_mail hook does not run. So it shouldn't create posts. Weird.
Shvakovski
Member
Posted 5 months ago #
Can you try to replay this kind of error? Make some form, try to apply hook and see?
I mean is there my bug anywhere making it work this way?
Shvakovski
Member
Posted 5 months ago #
Is there any after validate hook to use? It's not critical to use wp_insert_post before or after mailing I suppose.
I just tested your customization on the latest version of WordPress. Couldn't reproduced the problem.
Do you have other plugins installed? I guess there is another plugin firing wpcf7_before_send_mail hook.
Shvakovski
Member
Posted 5 months ago #