Skip to content

Instantly share code, notes, and snippets.

@kachi
Created March 9, 2012 03:56
Show Gist options
  • Save kachi/2004933 to your computer and use it in GitHub Desktop.
Save kachi/2004933 to your computer and use it in GitHub Desktop.
add_action( 'register_form', 'add_register_field' );
function add_register_field() { ?>
<p>
<label><?php _e('ここに質問内容') ?><br />
<input type="text" name="user_proof" id="user_proof" class="input" size="25" tabindex="20" /></label>
</p>
<?php }
add_action( 'register_post', 'add_register_field_validate', 10, 3 );
function add_register_field_validate( $sanitized_user_login, $user_email, $errors) {
if (!isset($_POST[ 'user_proof' ]) || empty($_POST[ 'user_proof' ])) {
return $errors->add( 'proofempty', '<strong>ERROR</strong>: 質問に答えなかったときのエラー文章' );
} elseif ( strtolower( $_POST[ 'user_proof' ] ) != 'ここが回答。これにマッチしないとエラーが出る' ) {
return $errors->add( 'prooffail', '<strong>ERROR</strong>: マッチしなかったときのエラー文章' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment