Viewing 8 replies - 1 through 8 (of 8 total)
  • Hi,

    We have received your query and it is now being processed. We will get back to you on this forum as soon as we can.

    Regards,
    BestWebSoft Support Team

    Hi doanthean1,

    Unfortunately, it is hard for us to tell, where exactly should the code be pasted, as there are so many different custom forms out there, and each of them requires an individual method of pasting the shortcode. If you’d like, we could help you with that, however, please note that this would be a paid service, since we will need some time to examine your form and add captcha to it.

    In case you are interested in our offer, please create a private ticket on our support forum: http://support.bestwebsoft.com/. In this ticket please provide a link to this post, so that we could recall the case immediately. We would also like to provide the user guide on adding captcha to the custom form, just in case.

    Please follow the instructions below.

    1. Install the Captcha plugin and activate it.
    2. Open the file with the form (where you would like to add the captcha to).
    3. Find a place to insert the code for the captcha output.
    4. Insert the necessary lines:

    if( function_exists( 'cptch_display_captcha_custom' ) ) { echo "<input
    type='hidden' name='cntctfrm_contact_action' value='true' />"; echo
    cptch_display_captcha_custom() } ;

    If the form is HTML you should insert the line with the PHP tags:

    <?php
    if( function_exists( 'cptch_display_captcha_custom' ) ) { echo
    "<input type='hidden' name='cntctfrm_contact_action' value='true'
    />"; echo cptch_display_captcha_custom(); } ?>

    5. Then you should add the lines to the function of the entered data checking

    if( function_exists( 'cptch_check_custom_form' ) &&
    cptch_check_custom_form() !== true ) echo "Please complete the
    CAPTCHA."

    or

    <?php if( function_exists(
    'cptch_check_custom_form' ) && cptch_check_custom_form() !==
    true ) echo "Please complete the CAPTCHA." ?>

    You could add this line to the variable and display this variable in the
    required place instead of echo "Please complete the CAPTCHA.". If
    there is a variable (responsible for the errors output) in the check
    function, this phrase can be added to this variable. If the function
    returns ‘true’, it means that you have entered captcha properly. In all
    other cases the function will return ‘false’.

    Regards,
    BestWebSoft Support Team

    Hi, I’m having the same problem. I have a custom form that has the cptch_display_captcha_custom() inserted in it (as required). When I display the form the captcha shows fine.

    My form is coded as follows: <form action=”/wp-content/custom-php/samplelogintest.php” method=”POST” name=”email-form”>

    In my validation routine “samplelogintest.php” I have inserted the
    cptch_check_custom_form() code in it, but it turns out that cptch_check_custom_form is not found.

    How can I get my homegrown PHP that validates the form, to successfully call “cptch_check_custom_form???

    Thread Starter doanthean1

    (@doanthean1)

    Thank you for very quick support, I’ve solved this problem by adding a small jquery code call a php file checking file then allow form submit after user put correct captcha. But something very strange, I would login successful to wordpress but when click log out, it threw error 403. If I login by native login form of wordpress, no problem when log out. Why this happened?. I means could you please explain more in this case? Thanks.

    Thread Starter doanthean1

    (@doanthean1)

    Here is the jQuery code check the Captcha
    jQuery(document).ready(function ($) {
    $(‘#captcha_button’).click(function(e)
    {
    e.preventDefault();
    var form1 = $(this).closest(‘form’);
    var data = {
    cntctfrm_contact_action: $(“input[name=’cntctfrm_contact_action’]”).val(),
    cptch_result : $(“input[name=’cptch_result’]”).val(),
    cptch_time : $(“input[name=’cptch_time’]”).val(),
    cptch_number : $(“input[name=’cptch_number’]”).val()
    };
    // Validate
    if ($.trim(data.cptch_number) == ”){
    alert(‘Captcha empty’);

    }
    else{
    $.ajax({
    type : ‘POST’,
    dataType : ‘json’,
    url : ‘{{ wp.get_template_directory_uri() }}/captcha_custom.php’,
    data : data,
    success : function (result){
    if (!result.hasOwnProperty(‘error’)){
    alert(‘Return Result not approve’);
    }
    else if (result[‘error’] == ‘success’){
    //alert(‘Correct Captcha’);
    form1.submit();
    }
    else if(result[‘error’] == ‘error’){
    alert(‘Incorrect Captcha’);

    }

    },
    error : function (){
    alert(‘Processing Error’);

    }
    });
    }
    return false;
    });

    Thread Starter doanthean1

    (@doanthean1)

    the captcha_custom.php:
    <?php
    require_once($_SERVER[‘DOCUMENT_ROOT’].’/wp-load.php’);
    $cptch_options = get_option( ‘cptch_options’ );
    $str_key = $cptch_options[‘cptch_str_key’][‘key’];

    $error = array(
    ‘error’ => ‘success’,

    );
    if ( isset( $_REQUEST[‘cntctfrm_contact_action’] ) || isset( $_REQUEST[‘cntctfrmpr_contact_action’] ) ) {
    /* If captcha doesn’t entered */
    if ( isset( $_REQUEST[‘cptch_number’] ) && “” == $_REQUEST[‘cptch_number’] ) {
    $error[‘error’] = ‘error’;
    }

    /* Check entered captcha */
    if ( isset( $_REQUEST[‘cptch_result’] ) && isset( $_REQUEST[‘cptch_number’] ) && isset( $_REQUEST[‘cptch_time’] )
    && 0 == strcasecmp( trim( cptch_decode( $_REQUEST[‘cptch_result’], $str_key, $_REQUEST[‘cptch_time’] ) ), $_REQUEST[‘cptch_number’] ) ) {
    $error[‘error’] = ‘success’;
    } else {
    $error[‘error’] = ‘error’;
    }
    } else
    {
    $error[‘error’] = ‘error’;
    }
    die (json_encode($error));

    Thread Starter doanthean1

    (@doanthean1)

    So about my new problem, error 403 when log out, please give me a clue. Thanks!

    Hi all,

    Unfortunately, it is hard for us to tell, which changes should be made to the code to get captcha working correctly, since there are so many custom forms out there, and each of them requires its own method of adding captcha. If you’d like, we could help you with that, but please note that this would be a paid service, since we will need some time to examine your custom form and add captcha to it. If you would like us to proceed with the customization, please create a private ticket on our support forum – http://support.bestwebsoft.com/, and provide a link to this post in that ticket, so that we could recall the case immediately.

    Regards,
    BestWebSoft Support Team

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘login form’ is closed to new replies.