<form name="registerform" id="registerform<?php $template->the_instance(); ?>" action="<?php $template->the_action_url( 'register' ); ?>" method="post">
<p>
<label for="user_login<?php $template->the_instance(); ?>"><?php _e( 'Username' ); ?></label>
<input type="text" name="user_login" id="user_login<?php $template->the_instance(); ?>" class="input" value="<?php $template->the_posted_value( 'user_login' ); ?>" size="20" />
</p>
<p>
<label for="user_email<?php $template->the_instance(); ?>"><?php _e( 'E-mail' ); ?></label>
<input type="text" name="user_email" id="user_email<?php $template->the_instance(); ?>" class="input" value="<?php $template->the_posted_value( 'user_email' ); ?>" size="20" />
</p>
<?php do_action( 'register_form' ); ?>
<p id="reg_passmail<?php $template->the_instance(); ?>"><?php echo apply_filters( 'tml_register_passmail_template_message', __( 'A password will be e-mailed to you.' ) ); ?></p>
<p class="submit">
<input type="submit" name="wp-submit" id="wp-submit<?php $template->the_instance(); ?>" value="<?php esc_attr_e( 'Зарегистрироваться' ); ?>" />
<input type="hidden" name="redirect_to" value="<?php $template->the_redirect_url( 'register' ); ?>" />
<input type="hidden" name="instance" value="<?php $template->the_instance(); ?>" />
<input type="hidden" name="action" value="register" />
</p>
</form>
Хочу ввести проверку поля user_login на минимальное количество символов? на другом форуме предложили такой вариант
<form>
<input required="" pattern="[A-Za-z0-9_-]{4,8}" />
<button type="submit">Зарегаться</button>
</form>
но если через firebug удалить свойство pattern= у формы, то проверка отключается. Нашел вот такой код https://github.com/itsananderson/wp-minimum...word-length.php
<?php
/*
* Plugin Name: Minimum Password Length
* Description: Enforce a minimum password length.
* Plugin URI: http://www.itsananderson.com/plugins/minimum-password-length
* Plugin Author: Will Anderson
* Author URI: http://www.itsananderson.com/
* Version: 1.0
*/
class WP_Minimum_Password_Length {
public static function start() {
add_action( 'user_profile_update_errors', array( __CLASS__, 'minimum_password_limit' ) );
}
public static function minimum_password_limit( &$errors ) {
// Edit this value to change the minimum password length.
// Set value to zero or disable plugin to remove length requirement.
$min_length = 7;
if ( !empty( $_POST['pass1'] ) && $_POST['pass1'] === $_POST['pass2'] && strlen( $_POST['pass1'] ) < $min_length ) {
$errors->add( 'min_pass_length', sprintf( __( '<strong>ERROR</strong>: Password must be at least %d characters long.' ), $min_length ), array( 'form-field' => 'pass1' ) );
}
}
}
WP_Minimum_Password_Length::start();
пытаюсь его адаптировать
<?php
class WP_Minimum_login_Length {
public static function start() {
add_action( 'user_profile_update_errors', array( __CLASS__, 'minimum_login_limit' ) );
}
public static function minimum_login_limit( &$errors ) {
$min_length = 4;
if ( !empty( $_POST['pass1'] ) && $_POST['pass1'] === $_POST['pass2'] && strlen( $_POST['pass1'] ) < $min_length ) {
$errors->add( 'min_login_length', sprintf( __( '<strong>ERROR</strong>: Password must be at least %d characters long.' ), $min_length ), array( 'form-field' => 'user_login' ) );
}
}
}
WP_Minimum_login_Length::start();
но незнаю как переделать 10 строку, чтобы она сверяла поле user_login с $min_length. Подскажите пожалуйста.