[contactform] showing captcha when not asked to

pending (8 posts) (5 voices)

  1. rob
    Member

    Hi again,

    I have the following code on the homepage

    [one_third_last]
    [button size="small" align="center"]Contact Us For A Free Consultation[/button]
    [contactform akismet="true"]
    [/one_third_last]

    And it looks like this:
    http://i.imgur.com/HVMro.png

    When I also do captcha="true", it shows two captcha boxes...

    Thoughts as to why it's displaying this?

    Thanks,
    Rob

    P.S. Please add a preview_post button :)

    Posted 9 months ago #
  2. Ruderic
    Support

    Hello,

    I think you have to remove the akismet="true" attribute from the shortcode, and the captcha will not appear.

    Posted 9 months ago #
  3. rob
    Member

    Ruderic, Thanks and you are right. But it seems like a bug if the captcha shows up if you enable akismet and it shows up TWICE if you enable akismet and captcha support. See shot here: http://i.imgur.com/Sr7eQ.png

    Posted 9 months ago #
  4. Ruderic
    Support

    Hello,

    I have analyzed the PHP code in charge of generating the captcha, but I could not find the bug. I will flag this thread, so the developers can take a look at this and tell you what's going on.

    Posted 9 months ago #
  5. Elliott
    Support

    Hello rob,

    Open up /wp-content/themes/infocus/lib/shortcodes/16-contact.php and change lines 76 - 81,

    $required = ( $matches[1][$i] == 'captcha' ? 'captcha'
    : ( empty( $matches[2][$i]['required'] ) ? false
    : ( $matches[1][$i] == 'email' ? 'email'
    : 'true'
    )));

    To this,

    if ($captcha == true) {
    $required = ( $matches[1][$i] == 'captcha' ? 'captcha'
    : ( empty( $matches[2][$i]['required'] ) ? false
    : ( $matches[1][$i] == 'email' ? 'email'
    : 'true'
    ))); }

    And then delete lines 161 - 186,

    if( $captcha == 'true' ) {
    
    	$field_id = "mysite_field{$i}{$form_id}";
    
    	if( isset( $errored_fields ) )
    		$required_error = ( !in_array( $field_id, $errored_fields ) ) ? '' : ' required_error';
    
    	$out .= '<div class="mysite_form_row captcha_row">';
    
    	$num1 = rand(1,10);
    	$num2 = rand(1,10);
    	$label = $num1 .' + '. $num2 . ' ';
    
    	$out .= '<label for="' . $field_id . '">' . $label . '</label>';
    
    	$out .= '<input type="text" name="' . $field_id . '" id="' . $field_id . '" class="textfield required' . $required_error .  '" value="' .
    	( isset( $_POST[$field_id] ) ? esc_attr( $_POST[$field_id] ) : '' ) . '" />';
    	$form_inputs['fields'][$field_id] = array( 'type' => 'captcha', 'label' => $label, 'required' => 'captcha' );
    
    	$form_inputs['fields'][$field_id]['captcha'] = $num1+$num2;
    
    	$out .= '</div>';
    }

    If that does not work for you then go ahead and revert the changes. Our devs know about this so we should hear a reply soon.

    Posted 9 months ago #
  6. Webtreats
    Support

    Hi rob,

    We're currently looking into this issue.

    Let us know if Elliott's above fix works for you.

    Posted 9 months ago #
  7. Strategerizer
    Member

    I have Awake 2.x. It looks like the captcha (math puzzle) always displays, even if Akismet and Captcha are off in the shortcode. If the Captcha is turned on, there will be two math quizzes displayed.

    Is this a known issue? Will it be fixed?

    I understand I can apply the fix mentioned above but I'd rather not fork my code from teh official drop if I can help it.

    Thanks!

    Posted 5 months ago #
  8. Elliott
    Support

    Hello Strategerizer,

    It's in our to do list so it should be fixed in the next update. In the meantime try the code above.

    Posted 5 months ago #

Reply

You must log in to post.

Construct WordPress Theme
Construct wordpress theme
Myriad WordPress Theme
Myriad wordpress theme
Method WordPress Theme
Method wordpress theme
Fusion WordPress Theme
Fusion wordpress theme
Elegance WordPress Theme
Elegance wordpress theme
Echelon WordPress Theme
Echelon wordpress theme
Dejavu WordPress Theme
Dejavu wordpress theme
Modular WordPress Theme
Modular wordpress theme