Skip to:
Content

BuddyPress.org

Ticket #5914: 5914.bp_signup_field_attributes.patch

File 5914.bp_signup_field_attributes.patch, 4.1 KB (added by r-a-y, 10 years ago)
  • src/bp-members/bp-members-template.php

     
    19311931        }
    19321932
    19331933/**
     1934 * Output the field attributes for a signup field on the registration page.
     1935 *
     1936 * @since BuddyPress (2.2.0)
     1937 *
     1938 * @param string $type The field type to output attributes for.
     1939 */
     1940function bp_signup_field_attributes( $type = '' ) {
     1941        echo bp_get_signup_field_attributes( $type );
     1942}
     1943        /**
     1944         * Get the field attributes for a signup field on the registration page.
     1945         *
     1946         * @since BuddyPress (2.2.0)
     1947         *
     1948         * @param string $type The field type to get attributes for.
     1949         */
     1950        function bp_get_signup_field_attributes( $type = '' ) {
     1951                $retval = '';
     1952                $attributes = array();
     1953
     1954                switch ( $type ) {
     1955                        case 'username' :
     1956                                $attributes['autocomplete'] = 'off';
     1957                                break;
     1958
     1959                        case 'email' :
     1960                                if ( wp_is_mobile() ) {
     1961                                        $attributes['autocapitalize'] = 'off';
     1962                                }
     1963                                break;
     1964
     1965                        case 'password' :
     1966                                $attributes['spellcheck'] = 'false';
     1967                                $attributes['autocomplete'] = 'off';
     1968
     1969                                if ( wp_is_mobile() ) {
     1970                                        $attributes['autocorrect']    = 'false';
     1971                                        $attributes['autocapitalize'] = 'off';
     1972                                }
     1973                                break;
     1974                }
     1975
     1976                /**
     1977                 * Filter the field attributes for a signup field before rendering output.
     1978                 *
     1979                 * @since BuddyPress (2.2.0)
     1980                 *
     1981                 * @param array  $attributes The field attributes
     1982                 * @param string $type       The field type
     1983                 */
     1984                $attributes = apply_filters( 'bp_get_signup_field_attributes', $attributes, $type );
     1985
     1986                foreach( (array) $attributes as $attr => $value ) {
     1987                        $attr  = sanitize_title( $attr );
     1988                        $value = esc_attr( $value );
     1989                        $retval .= " {$attr}=\"{$value}\"";
     1990                }
     1991
     1992                echo $retval;
     1993        }
     1994
     1995/**
    19341996 * Output the 'signup_with_blog' value submitted during signup.
    19351997 */
    19361998function bp_signup_with_blog_value() {
  • src/bp-templates/bp-legacy/buddypress/members/register.php

     
    3131
    3232                                <label for="signup_username"><?php _e( 'Username', 'buddypress' ); ?> <?php _e( '(required)', 'buddypress' ); ?></label>
    3333                                <?php do_action( 'bp_signup_username_errors' ); ?>
    34                                 <input type="text" name="signup_username" id="signup_username" value="<?php bp_signup_username_value(); ?>" />
     34                                <input type="text" name="signup_username" id="signup_username" value="<?php bp_signup_username_value(); ?>" <?php bp_signup_field_attributes( 'username' ); ?>/>
    3535
    3636                                <label for="signup_email"><?php _e( 'Email Address', 'buddypress' ); ?> <?php _e( '(required)', 'buddypress' ); ?></label>
    3737                                <?php do_action( 'bp_signup_email_errors' ); ?>
    38                                 <input type="email" name="signup_email" id="signup_email" value="<?php bp_signup_email_value(); ?>" />
     38                                <input type="email" name="signup_email" id="signup_email" value="<?php bp_signup_email_value(); ?>" <?php bp_signup_field_attributes( 'email' ); ?>/>
    3939
    4040                                <label for="signup_password"><?php _e( 'Choose a Password', 'buddypress' ); ?> <?php _e( '(required)', 'buddypress' ); ?></label>
    4141                                <?php do_action( 'bp_signup_password_errors' ); ?>
    42                                 <input type="password" name="signup_password" id="signup_password" value="" class="password-entry" />
     42                                <input type="password" name="signup_password" id="signup_password" value="" class="password-entry" <?php bp_signup_field_attributes( 'password' ); ?>/>
    4343                                <div id="pass-strength-result"></div>
    4444
    4545                                <label for="signup_password_confirm"><?php _e( 'Confirm Password', 'buddypress' ); ?> <?php _e( '(required)', 'buddypress' ); ?></label>
    4646                                <?php do_action( 'bp_signup_password_confirm_errors' ); ?>
    47                                 <input type="password" name="signup_password_confirm" id="signup_password_confirm" value="" class="password-entry-confirm" />
     47                                <input type="password" name="signup_password_confirm" id="signup_password_confirm" value="" class="password-entry-confirm" <?php bp_signup_field_attributes( 'password' ); ?>/>
    4848
    4949                                <?php do_action( 'bp_account_details_fields' ); ?>
    5050