BuddyDev

Search

Username changer – Disallow space, missing error messages and remove header

  • Participant
    Level: Initiated
    Posts: 2
    Derrick on #42273

    Hi, awesome plugin!

    I have used this code to disallow space in username change

    /**
     * Validate user name
     *
     * @param WP_Error $error Error object.
     * @param string   $new_user_name New user name.
     *
     * @return string
     */
    function buddydev_validate_user_name( $error, $new_user_name ) {
    
    	if ( $error->has_errors() ) {
    		return $error;
    	}
    
    	if ( preg_match('/\s/',$new_user_name ) ) {
    		$error->add( 'contains_spaces', __( 'User name can not have space in it' ) );
    	}
    
    	return $error;
    }
    add_filter( 'bp_username_changer_validation_errors', 'buddydev_validate_user_name', 10, 2 );
    

    However, there are no error messages shown to the user if he/she uses a space in the username.

    Also, how do I remove the header “Change Username” from the settings page? Thank you!!

    Cheers,
    Derrick

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #42277

    Hello Derrick,

    Welcome to the BuddyDev forums. Please let me know are you using BuddyPress or BuddyBoss Platform. If BuddyPress which theme you are using?

    Regards
    Ravi

  • Participant
    Level: Initiated
    Posts: 2
    Derrick on #42281

    Thanks for the reply! Buddypress, I’m using custom theme

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #42293

    Hello Derrick,

    I have tested this plugin and it is working fine for me. Are you able to see other feedback messages?.
    This issue is coming probably with your custom theme. Please try after switching to the default WordPress theme. Also, let me know which template pack you are using i.e. Nouveau or Legacy.

    Regards
    Ravi

  • Participant
    Level: Initiated
    Posts: 2
    Derrick on #42294

    Thanks for the reply. I guess I’ll check with my dev for this issue, thanks again.

You must be logged in to reply to this topic.

This topic is: not resolved