Skip to:
Content
Pages
Categories
Search
Top
Bottom

Cant add WP user as forum moderator as username has space in it


  • dozza
    Participant

    @dozza

    I have a memberpress/bbPress/Wordpress site with about 100 members. I was trying to make a user a moderator of a particular forum. I was able to change her role to a moderator by editing her user profile OK. But when I add her username to the moderator field within the edit forum screen it spins on update but never registers the username as moderator.

    I then notice the username in question is of the format ‘firstname dot space secondname’

    I didn’t think WP allowed usernames with spaces or dots (periods) but apparently, it does and the username is created when they register via a Memberpress form. By default, they are made forum participants upon registering. I want to upgrade this user to be a moderator of a specific forum.

    The user HAS managed to post a topic in a forum already as a participant.

    So i’m assuming that the problem lies in bbPress NOT allowing spaces in usernames when you try to assign them to be a moderator of a specific forum?

    I was reading a 15 year old thread here where @howtogeek provides some plugin code. I tried saving this to a zipped .php file and adding it as a plugin but Wordfence said that wasn’t a good idea, so I’m not confident using 15-year old code is such a good workaround.

    There was another old thread from 8yrs here ago where @joop.stringer suggests tweaking permalinks but I can’t seem to figure that out either.

    I’ve come across this which will maybe help me prevent this from happening again.

    But can anyone confirm that the space in the username IS the reason I can’t assign a moderator
    role user to be the moderator of a specific forum, and if there is any more recent knowledge on this issue? i.e. does bbPress actually allow spaces in usernames now?

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

  • Robin W
    Moderator

    @robin-w

    I just tried adding a user with a space in the name ie ‘test user’

    then in dashboard>forums>edit forum>moderators I typed in ‘test user’

    it did not pick up the name as I typed it so I had to type the full name, but it did accept it, and added it correctly to the forum database.

    per forum moderators are relatively new, and the 15 yr old and 8 year old threads would have been for bbpress version 1.

    so on my test site bbpress does allow moderators with spaces in the names.

    my next suggestion would be it could be a theme or plugin issue

    Themes

    As a test switch to a default theme such as twentytwenty, and see if this fixes.

    Plugins

    If that doesn’t work, also deactivate all plugins apart from bbpress and see if this fixes. if it does, re-enable one at a time to see which is causing the error.

    If you cannot do this to your site (say because it is live) then use the ‘troubleshooting’ features of this plugin to let you test without affecting other users

    Health Check & Troubleshooting

    Then come back


    dozza
    Participant

    @dozza

    @robin-w Thanks for your feedback, insight and testing on my behalf.

    I’ve used the troubleshooter to run the site using 2022 theme and only bbpress. Still won’t allow me to add the user to the forum.

    Also the username has the initial of firstname and lastname capitalised so it is more accurately of the format ‘Firstname. Secondname’ – i note that in the ‘all forums’ screen, the moderators columns are all displayed lowercase. So i tried adding the username in the format ‘firstname. secondname’ but to no avail.

    To further narrow down the issue I successfully created a new member/user on the site with the actual username ‘Firstname. Secondname’. After upgrading their Forum role to moderator, i attempted to added them as a moderator to a forum. So i added ‘Firstname. Secondname’ (without inverted commas) into the Forum Moderators field and hit update. This then left the field with ‘firstname-lastname’ in place. So when adding the moderator it swaps the ‘dot space’ to a hyphen and makes all characters lowercase.

    With this new discovery, I tried adding the original problem username back as a forum moderator, all lowercase with the ‘dot space’ replaced with a hyphen.

    But it didn’t accept it.

    So I’m confused now as to why it works with one new user in the same format as the old user (which doesn’t work)?

    See the above testing in action here

    With the new knowledge, I finally retried adding the troublesome username in lowercase with hyphen whilst in a similar troubleshooting set-up but again it didn’t accept it.

    Any further thoughts?


    Robin W
    Moderator

    @robin-w

    Thanks for that – very useful.

    Wordpress has a bewildering set of names including username, user display name and user nicename

    As far as I can see, bbpress seems to be using the user database setting for user nicename.

    So can you try adding this code

    add_filter( 'manage_users_columns', 'rew_add_user_nicename', 20, 1);
    add_filter( 'manage_users_custom_column','rew_add_user_row', 20, 3 );
    
    function rew_add_user_nicename($columns)  {
    	$new = array();
      foreach($columns as $key => $title) {
    	 $new[$key] = $title;
    	 //add the 2 columns after the forum role column
        if ($key=='bbp_user_role') {
    	$new['nicename'] = 'Nicename';
    	}
        
      }
     return $new;
    }
    
    function rew_add_user_row($retval = '', $column_name = '', $user_id = 0) {
    	if ($column_name == 'nicename') {
    		$user_info = get_userdata($user_id);
    		$user_nicename = $user_info->user_nicename;
    		$retval = '-->'.$user_nicename.'<--';
    	}
    return $retval ;
    }

    Put this in your child theme’s function file –

    ie wp-content/themes/%your-theme-name%/functions.php

    where %your-theme-name% is the name of your theme

    or use

    Code Snippets

    This will add a column to the dashboard>users table to show you exactly what is set as the user nicename. I have enclosed it in arrows eg

    –>name here<–

    so you can see if there are leading or trailing spaces.

    try adding that name to the moderators and see if that works?

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