Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>: マッチしなかったときのエラー文章' ); | |
} | |
} |
Screen shot
Note
Description | functions.phpに追記。マッチするキーワードに気をつける事 |
---|---|
WordPress Ver. | 3.3.1 |
Via | WP Glee |