Fix notices. Simplify checkbox logic. Props SergeyBiryukov. fixes #19670

git-svn-id: http://svn.automattic.com/wordpress/trunk@19850 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2012-02-07 17:12:46 +00:00
parent 572242350a
commit 1438d03330
2 changed files with 4 additions and 9 deletions

View File

@ -439,7 +439,7 @@ function wpmu_validate_user_signup($user_name, $user_email) {
$maybe = array();
preg_match( '/[a-z0-9]+/', $user_name, $maybe );
if ( $user_name != $orig_username || $user_name != $maybe[0] ) {
if ( $user_name != $orig_username || ( !empty( $maybe ) && $user_name != $maybe[0] ) ) {
$errors->add( 'user_name', __( 'Only lowercase letters (a-z) and numbers are allowed.' ) );
$user_name = $orig_username;
}

View File

@ -229,13 +229,8 @@ function signup_user($user_name = '', $user_email = '', $errors = '') {
if ( !is_wp_error($errors) )
$errors = new WP_Error();
if ( isset( $_POST[ 'signup_for' ] ) )
$signup[ esc_html( $_POST[ 'signup_for' ] ) ] = 'checked="checked"';
else
$signup[ 'blog' ] = 'checked="checked"';
//TODO - This doesn't seem to do anything do we really need it?
$signup['user'] = isset( $signup['user'] ) ? $signup['user'] : '';
$signup_for = isset( $_POST[ 'signup_for' ] ) ? esc_html( $_POST[ 'signup_for' ] ) : 'blog';
// allow definition of default variables
$filtered_results = apply_filters('signup_user_init', array('user_name' => $user_name, 'user_email' => $user_email, 'errors' => $errors ));
@ -257,10 +252,10 @@ function signup_user($user_name = '', $user_email = '', $errors = '') {
<?php } elseif ( $active_signup == 'user' ) { ?>
<input id="signupblog" type="hidden" name="signup_for" value="user" />
<?php } else { ?>
<input id="signupblog" type="radio" name="signup_for" value="blog" <?php echo $signup['blog'] ?> />
<input id="signupblog" type="radio" name="signup_for" value="blog" <?php checked( $signup_for, 'blog' ); ?> />
<label class="checkbox" for="signupblog"><?php _e('Gimme a site!') ?></label>
<br />
<input id="signupuser" type="radio" name="signup_for" value="user" <?php echo $signup['user'] ?> />
<input id="signupuser" type="radio" name="signup_for" value="user" <?php checked( $signup_for, 'user' ); ?> />
<label class="checkbox" for="signupuser"><?php _e('Just a username, please.') ?></label>
<?php } ?>
</p>