i have created custom login page when captcha empty , long processed trying error message $error_message
passed onto $error_msg
.
i working 2 wp plugins, 1 no captcha recaptcha plugin , other client template portal.
the following full code of custom-login.php
<?php class ncr_custom_login_captcha extends ncr_no_captcha_recaptcha { public static function initialize() { // initialize if login activated if ( isset(self::$plugin_options['captcha_login']) && self::$plugin_options['captcha_login'] == 'yes') { // add captcha header script wordpress header add_action( 'wp_head', array( __class__, 'header_script' ) ); // adds captcha custom login form add_action( 'custom_captcha_login', array( __class__, 'display_captcha' ) ); // authenticate captcha answer add_action( 'custom_authenticate_user', array( __class__, 'validate_captcha_custom_login' ), 10, 2 ); } } /** * verify captcha answer * * @param $user string login username * @param $password string login password * * @return wp_error|wp_user */ public static function validate_captcha_custom_login( $user, $password ) { if ( ! isset( $_post['g-recaptcha-response'] ) || ! self::captcha_verification() ) {} $error_msg .= 'i want show message'; return false; } }
i have tried following
public static function validate_captcha_custom_login( $user, $password ) { if ( ! isset( $_post['g-recaptcha-response'] ) || ! self::captcha_verification() ) {} $error_msg .= 'i want show message'; return false; }
the following login form template page other plugin uses
{if $action == 'login'} {if !empty($msg_ve)} <p class="message">{$msg_ve}</p> {/if} <form method="post" action="{if !empty($login_url)}{$login_url}{/if}" id="loginform" name="loginform"> {if !empty($somefields)}{$somefields}{/if} {if !empty($error_msg)} <p class="message wpc_error">{$error_msg}</p> {/if} {if !empty($custom_login_error_msg)} <p class="message wpc_error">{$custom_login_error_msg}</p> {/if} <p> <label for="user_login">{if !empty($labels.username)}{$labels.username}{/if}<br> <input type="text" tabindex="10" size="20" value="" class="input" id="user_login" name="log"></label> </p> <p> <label for="user_pass">{if !empty($labels.password)}{$labels.password}{/if}<br> <input type="password" tabindex="20" size="20" value="" class="input" id="user_pass" name="pwd"></label> </p> {do_action( 'custom_captcha_login' )} <p class="forgetmenot"><label for="rememberme"><input type="checkbox" tabindex="90" value="forever" id="rememberme" name="rememberme"> {if !empty($labels.remember)}{$labels.remember}{/if}</label></p> <p class="submit"> <label> <input type="submit" tabindex="100" value="log in" class="button-primary" id="wp-submit" name="wp-submit"> <input type="hidden" value="" name="redirect_to"> </label> </p> {if isset($lostpassword_href) && !empty($lostpassword_href)} <p id="nav"> <label> <a title="password lost , found" href="{$lostpassword_href}">lost password?</a> </label> </p> {/if} </form> {elseif $action == 'lostpassword' && isset($lostpassword_href) && !empty($lostpassword_href) } <form method="post" action="{if !empty($login_url)}{$login_url}{/if}" id="loginform" name="loginform"> {if !empty($error_msg)} <p class="message wpc_error">{$error_msg}</p> {/if} <p> <label for="user_login">{if !empty($labels.email)}{$labels.email}{/if}<br> <input type="text" tabindex="10" size="35" value="" class="input" id="user_login" name="user_login"></label> </p> <p class="submit"> <label> <input type="submit" tabindex="100" value="{if !empty($labels.get_new_password)}{$labels.get_new_password}{/if}" class="button button-primary button-large" id="wp-submit" name="wp-submit"> </label> </p> <p id="nav"> <label> <a title="back login page" href="{$login_href}">remember password?</a> </label> </p> </form> {elseif ( $action == 'rp' || $action == 'resetpass' ) && !empty($lostpassword_href) } <form method="post" action="{if !empty($login_url)}{$login_url}{/if}" id="loginform" name="loginform"> {if !empty($error_msg)} <p class="message wpc_error">{$error_msg}</p> {/if} {if !in_array($error_msg, $check_invalid)} <input type="hidden" id="user_login" value="{if !empty($user_login)}{$user_login}{/if}" autocomplete="off" /> <p> <label for="pass1">{if !empty($labels.new_password)}{$labels.new_password}{/if}<br /> <input type="password" name="pass1" id="pass1" class="input" size="35" value="" autocomplete="off" /></label> </p> <p> <label for="pass2">{if !empty($labels.confirm_new_password)}{$labels.confirm_new_password}{/if}<br /> <input type="password" name="pass2" id="pass2" class="input" size="35" value="" autocomplete="off" /></label> </p> <div id="pass-strength-result">{if !empty($labels.strength_indicator)}{$labels.strength_indicator}{/if}</div> <p class="description indicator-hint">{if !empty($labels.hint_indicator)}{$labels.hint_indicator}{/if}</p> <br class="clear" /> <p class="submit"><label><input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="{if !empty($labels.reset_password)}{$labels.reset_password}{/if}" /></label> </p> </form> {/if} {/if}
try this, working me.
in validation
if(validationfunctions failed) { $error_msg .= '<p class="error">i want show message</p>'; return false; }
and in page
if (!empty($error_msg)) { echo $error_msg; }
do not set error message inside function.
Comments
Post a Comment