Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Alessandro Tesoro

    (@alessandrotesoro)

    Hello,

    There isn’t a way to add a captcha into the form however by modifying the plugin it’s possible to add a simple math verification form.

    If you’d like to go this way, let me know and I’ll provide you the instructions.

    Regards.

    Thread Starter Fay Zhang

    (@fay-zhang)

    Yeah, I’ll do that. Please teach me how to do that. Thank you.

    Plugin Author Alessandro Tesoro

    (@alessandrotesoro)

    Ok, so to add a new field to the booking form you can use the built-in filter. You can add this code at the bottom of your theme’s functions.php file.

    function wprm_custom_captcha( $booking_fields ) {
    // Add the new field to the booking form
    $booking_fields[] = array(
    'type' => 'text',
    'label' => '2+2 = ?',
    'name' => 'wprm_math',
    'placeholder' => '',
    'value' => '',
    'required' => true
    );
    
    return $booking_fields;
    }
    add_filter('wprm_booking_form_fields', 'wprm_custom_captcha' );

    You should now see a new field into the form.

    Now we need to tell the form what should do with that field. Unfortunately as of yet, there isn’t a filter to adjust the validation process of the form so we’ll have to edit the plugin manually.

    Open file includes/class-wprm-bookings.php of the plugin and locate line 341 which should be empty. And add this code

    if (isset($_POST['wprm_math']) && $_POST['wprm_math'] !== '4' ) {
    $errors->add( 'cheater2', __('Are you trying to cheat?','wprm'));
    }

    It simply verifies whether the submitted value for that field is 4.

    Regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘start to get spam emails’ is closed to new replies.