Forums

Contact Form 7
wpcf7_before_send_mail and CAPTCHA (8 posts)

  1. 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/

  2. Takayuki Miyoshi
    Member
    Posted 5 months ago #

    What CAPTCHA do you use and how do you use it?

  3. 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.

  4. Takayuki Miyoshi
    Member
    Posted 5 months ago #

    If CAPTCHA validation get failed wpcf7_before_send_mail hook does not run. So it shouldn't create posts. Weird.

  5. 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?

  6. 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.

  7. Takayuki Miyoshi
    Member
    Posted 5 months ago #

    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.

  8. Shvakovski
    Member
    Posted 5 months ago #

    Thanks. Will check.

Reply

You must log in to post.

About this Plugin

About this Topic