Skip to:
Content
Pages
Categories
Search
Top
Bottom

Set textfield max characters


  • spinningplays
    Participant

    @spinningplays

    Hi,

    how can I set the max. characters that could be entered in a textfield? I need this for registration and later editting of the fields in profile tab, because I don’t want my users to have a 999 character long name.

    With best regards

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

  • spinningplays
    Participant

    @spinningplays

    I need help pls :/


    David Cavins
    Keymaster

    @dcavins

    That depends on where you’re using it. You could use a bp_signup_validate filter to check that a username has certain characteristics. But for profile fields or other places, you’d have to enforce it some other way.

    Here’s an example of how you might disalloe long usernames:

    
    add_action('bp_signup_validate', function() {
    	if ( isset( $_POST[ 'signup_username' ] ) && strlen( $_POST[ 'signup_username' ] ) > 60 ) {
    		$bp = buddypress();
    		$bp->signup->errors['signup_username'] = 'Geez, your username is really long.';
    	}
    } );
    

    spinningplays
    Participant

    @spinningplays

    Where do I should paste this code in?


    Venutius
    Moderator

    @venutius

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar