Support » Plugin: User Role Editor » [Plugin: User Role Editor] Error with capabilities is_role

  • Resolved mingya


    I keep getting error like this on page:
    array_filter() expects 2 parameter to be a valid callback, class stdClass does not have a method is_role

    Between the plugins and theme I used, only user role editor is using is_role. Could you give me some direction on why this happened? I did not try to add any new role, however, I rename the role name using a function method (for example: Administrator -> Owner).

    Any idea where this error comes from and how to fix it?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Vladimir Garagulia


    As you saw already from URE code

    global $wp_roles;
    if (!isset($wp_roles)) {
       $wp_roles = new WP_Roles();
    if ($wp_roles->is_role($user_role_copy_from)) {

    $wp_roles is not the simple stdClass object, it should be WP_Roles class from capabilities.php
    If $wp_roles is not WP_Roles object, your blog roles set could be corrupted somehow…
    Why you decided to rename Administrator role? URE uses that name directly to prohibit this critical role unauthorized changes. I’m not sure that WordPress itself doesn’t use ‘Administrator’ role name somewhere in the code. You should rename or delete ‘Administrator’ user. That’s critical for security reasons. But ‘Administrator’ role name is not your blog security related.

    “Administrator” is the default admin role built in to wordpress. Renaming is simply the name that appears on the backend interface. not the actual role itself. I wiped out the whole db and reinstall, so corrupted role data is out of the picture.

    Plugin Author Vladimir Garagulia


    I agree with you. Moreover as you do not try to add new role, code above is not executed at all. Can you show full error message from your site? Of course without real paths in it? It’s interesting for me to see PHP call stack trace.

    Here is the error message. This line keeps repeating for every page query.

    [07-May-2012 03:19:15] PHP Warning: array_filter() [<a href='function.array-filter'>function.array-filter</a>]: The second argument, 'stdClass::is_role', should be a valid callback in /wp-includes/capabilities.php on line 676

    I have the latest plugin installed v3.6.1

    Plugin Author Vladimir Garagulia


    Thanks for the additional information. You get this error from line 676 of /wp-includes/capabilities.php, which belongs to function get_role_caps() and contains this code:

    $this->roles = array_filter( array_keys( $this->caps ), array( &$wp_roles, 'is_role' ) );

    for WordPress version 3.3.2
    1st: URE plugin doesn’t use this method – get_role_caps(). So I offer you to deactivate URE plugin for the moment and see – the error should be still there.
    2nd: I placed breakpoint on this line at PHP debugger and check my test WordPress installation. This method was not called neither for front-end, neither for back-end for my set of plugins and default theme.
    Thus, I suppose that some of other your installed plugins or theme uses it somehow. Please check not is_role() call, but get_role_caps(). May be you find something new information.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: User Role Editor] Error with capabilities is_role’ is closed to new replies.