can't assign "no role" to users (4 posts)

  1. roganty
    Posted 7 years ago #

    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

  2. TheDeadMedic
    Posted 6 years ago #

    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;
  3. MichaelH
    Posted 6 years ago #

    Adding this for reference:

  4. trecords1
    Posted 6 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic