Skip to:
Content
Pages
Categories
Search
Top
Bottom

Why are display name char amounts not limited?


  • disent
    Participant

    @disent

    Isn’t it silly that I can name myself “lllllllllllllllllllllllllllllllllllll” and mess up the whole site? Am I missing something?

    I understand WP manages display names somehow, but I can’t believe I haven’t found a fix that doesn’t involve modifying WP Core in 3 hours.

    What I would want:
    usernames displayed everywhere (BuddyPress Usernames Only plugin (still fails when using the search feature – only finds nicknames)).

    OR Even better

    Users can’t change their nickname (just hiding the box is silly and bypassable).
    Nicknames are limited to a certain amount of characters.

Viewing 7 replies - 1 through 7 (of 7 total)

  • modemlooper
    Moderator

    @modemlooper

    open file edit.php in buddypress/bp-templates/bp-legacy/buddypress/members/single/profile/edit.php

    find:

    <?php if ( ‘textbox’ == bp_get_the_profile_field_type() ) : ?>
    
    <label for=”<?php bp_the_profile_field_input_name(); ?>”><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( ‘(required)’, ‘buddypress’ ); ?><?php endif; ?></label>
    <input type=”text” name=”<?php bp_the_profile_field_input_name(); ?>” id=”<?php bp_the_profile_field_input_name(); ?>” value=”<?php bp_the_profile_field_edit_value(); ?>” <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required=”true”<?php endif; ?>/>
    
    <?php endif; ?>

    change to:

    <?php if ( ‘textbox’ == bp_get_the_profile_field_type() ) : ?>
    
    <label for=”<?php bp_the_profile_field_input_name(); ?>”><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( ‘(required)’, ‘buddypress’ ); ?><?php endif; ?></label>
    <input <?php if ( bp_get_the_profile_field_input_name() == ‘field_1′) : ?>maxlength=”10″<?php endif; ?> type=”text” name=”<?php bp_the_profile_field_input_name(); ?>” id=”<?php bp_the_profile_field_input_name(); ?>” value=”<?php bp_the_profile_field_edit_value(); ?>” <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required=”true”<?php endif; ?>/>
    
    <?php endif; ?>

    that will limit the profile username form field. To limit the sign up name you add maxlength to the register.php form input for username. change max length to however long you want to cut the name off at.

    <input maxlength="10" type="text" name="signup_username" id="signup_username" value="<?php bp_signup_username_value(); ?>" />


    modemlooper
    Moderator

    @modemlooper

    If you don’t want to edit core files then create the same files in your theme folder with the same folder structure and those files will override BP.

    copy file from:

    buddypress/bp-templates/bp-legacy/buddypress/members/single/profile/edit.php

    to:

    your-theme-folder/buddypress/members/single/profile/edit.php

    No that’s cleared up you may like to edit your account display name here to something that doesn’t mess up the site 😉


    disent
    Participant

    @disent

    Thank you for your reply, thats the fix I came up with too, however it’s only a client sided fix and anyone who knows how to use inspection tool or how to modify http post fields can bypass this.


    modemlooper
    Moderator

    @modemlooper

    You still need to use a maxlength on input for the user. If you want to block a bypass then you can filter

    http://etivite.com/api-hooks/buddypress/trigger/apply_filters/xprofile_data_value_before_save/


    disent
    Participant

    @disent

    Thank you modemlooper, this solution pleases me. (even though I edited the core file bp-xprofile-filters.php, because I failed to do it in functions.php)

    🙂


    ananwebman
    Participant

    @ananwebman

    hi @disent

    you can use :

    if( strlen( $user_name ) >= 13 )
    		$errors->add( 'user_name',  __( 'Username must be 12 characters maximum', 'buddypress' ) );	

    in /plugins/buddypress/bp-members/bp-members-functions.php
    inside function bp_core_validate_user_signup ()

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Why are display name char amounts not limited?’ is closed to new replies.
Skip to toolbar