WordPress.org

Support

Support » How-To and Troubleshooting » can’t assign “no role” to users

can’t assign “no role” to users

  • I have a problem with spam users registering on my blog, I get about 2 to 3 a week, and normally I would just change their role to “No role for this blog”

    Well that was before 2.8!

    Now WordPress gives me the error:

    You can’t give users that role.

    Has this “feature” been disabled?
    Or is it a bug?

    Thanks for any help you can give

Viewing 3 replies - 1 through 3 (of 3 total)
  • It’s thanks to the function get_editable_roles (currently on line 284 in wp-admin/includes/user.php).

    Since the introduction of this function in 2.8, when a user is added or updated, the role to be assigned is cross-referenced with the return of get_editable_roles.

    If the new role is not one of the ‘editable roles’, you get the error roganty was having.

    The fix is to filter the editable roles, and add an empty key to the roles array.

    add_filter('editable_roles', 'fix_no_role_for_this_blog');
    
    function fix_no_role_for_this_blog($roles)
    {
        $roles[''] = true;
        return $roles;
    }

    Adding this for reference:
    http://core.trac.wordpress.org/ticket/10833

    Please can someone explain me how to use this? I can`t understand what to replace, also ticket. I have found this string and replaced then user.php stopped working. I use wordpress MU 2.8.6.
    Please, explain me how to do this.
    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘can’t assign “no role” to users’ is closed to new replies.
Skip to toolbar