Demonstrates a Participants Database custom template that adds a reCAPTCHA to the Participant Login form.
<?php | |
/** | |
* @version 1.0 | |
* | |
* the uses a recaptcha field in the login form if available | |
* | |
* @global PDb_reCAPTCHA $PDb_reCAPTCHA | |
*/ | |
global $PDb_reCAPTCHA; | |
$recaptcha_fieldname = 'captcha'; // change this to match your captcha field name | |
$recaptcha_field = new PDb_Field_Item( $recaptcha_fieldname ); | |
$is_recaptcha = is_object($PDb_reCAPTCHA) && $recaptcha_field->form_element() === 'captcha' && in_array( 'recaptcha', $recaptcha_field->attributes() ); | |
$is_invisible = $PDb_reCAPTCHA->plugin_options['size'] === 'invisible'; | |
?> | |
<div id="pdbx-login" class="form-horizontal pdb-recaptcha"><?php if ( $feedback ) : ?> | |
<?php echo $feedback ?> | |
<?php endif ?> | |
<form method="post" > | |
<?php /* these hidden fields must be present */ ?> | |
<input type="hidden" name="pdbx-ser" value="<?php echo $record_page ?>" /> | |
<input type="hidden" name="form" value="pdbx-login" /> | |
<div class="control-group"> | |
<label class="control-label" for="login_name" ><?php echo $this->username_field->title ?></label> | |
<div class="controls"> | |
<input type="text" name="<?php echo $this->username_field->name ?>" value="<?php echo filter_input( INPUT_POST, $this->username_field->name, FILTER_SANITIZE_STRING ) ?>" /> | |
</div> | |
</div> | |
<?php if ( $this->showing_password_field() ) : ?> | |
<?php $input_type = $this->passwords_encrypted() ? 'password' : 'text'; ?> | |
<div class="control-group"> | |
<label class="control-label" for="login_password" ><?php echo $this->password_field->title ?></label> | |
<div class="controls"> | |
<input type="<?php echo $input_type ?>" name="<?php echo $this->password_field->name ?>" value="" /> | |
</div> | |
</div> | |
<?php endif ?> | |
<?php if ( $is_recaptcha && ! $is_invisible ) : ?> | |
<div class="control-group"> | |
<label class="control-label" for="login_password" ><?php echo $recaptcha_field->title() ?></label> | |
<div class="controls"> | |
<?php $recaptcha_field->print_element() ?> | |
</div> | |
</div> | |
<?php endif ?> | |
<div class="control-group"> | |
<div class="controls"> | |
<?php if ( $is_recaptcha && $is_invisible ) { | |
$recaptcha_field->print_element(); | |
} ?> | |
<input type="submit" name="submit" value="<?php echo $login_button_text ?>" /><div class="retrieve-link"><?php if ( $show_retrieve_link ) $this->print_retrieve_link() ?></div> | |
</div> | |
</div> | |
</form> | |
</div> |
This comment has been minimized.
This comment has been minimized.
If you don't know how to use this template, read this: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
Of course, you must be using the PDB reCAPTCHA add-on for this to work.
Make sure line 10 is correct for the name of your captcha field.