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(); ?>" />
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 😉
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.
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/
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)
🙂
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 ()