field display

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  function guest_captcha_field() {
    global $si_captcha_url, $si_captcha_opt;
    global $oqp_form;
      
    if (!$oqp_form->is_first_step()) return false;
    if($oqp_form->action!=_x('create','slug','oqp')) return false;
    
    $si_image_captcha = new siCaptcha();

    // the captch html
    // Test for some required things, print error message right here if not OK.
    if ($si_image_captcha->si_captcha_check_requires()) {
      ?>
      <p class="oqp-form-field  required">
        <label for="captcha_code">
          <?php _e('Captcha code','oqp');?>*
        </label>
        <input id="captcha_code" name="captcha_code" type="text" size="6" style="width:65px;"/>
        <div>
          <?php echo $si_image_captcha->si_captcha_captcha_html('si_image_oqp','oqp');?>
        </div>
      </p>
      <?php
    }
  }

field validation

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
  function guest_captcha_check(){
    global $si_captcha_dir;
    global $oqp_form;


    if(!$_POST['oqp-form-slug']) return false;

    if(!$oqp_form->is_first_step()) return false;
    if(!$oqp_form->action==_x('create','slug','oqp')) return false;

    if (empty($_POST['captcha_code']) || $_POST['captcha_code'] == '') {
      $oqp_form->notices->error(27,'before_form'); //empty captcha
      $errors=true;
    } else {
      $captcha_code = trim(strip_tags($_POST['captcha_code']));
      require_once "$si_captcha_dir/securimage.php";
      $img = new Securimage();
      $img->form_id = 'oqp'; // makes compatible with multi-forms on same page
      $valid = $img->check("$captcha_code");
      
      
      
      // Check, that the right CAPTCHA password has been entered, display an error message otherwise.
      if(!$valid) {
        $oqp_form->notices->error(28,'before_form'); //wrong captcha
        $errors=true;
      }
    }
    
    if($errors){
      $redirect_args['oqp_action']=$oqp_form->action;
      $redirect_args['oqp_step']=$oqp_form->get_step_slug($oqp_form->current_step);
      $redirect_url = add_query_arg($redirect_args,$oqp_form->url);
      wp_redirect( $redirect_url );die();
    }
    

  }