WordPress.org

Ready to get started?Download WordPress

Forums

User Role Editor
[resolved] Error with capabilities is_role (6 posts)

  1. mingya
    Member
    Posted 1 year ago #

    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?

    http://wordpress.org/extend/plugins/user-role-editor/

  2. Vladimir Garagulya
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  3. mingya
    Member
    Posted 1 year ago #

    "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.

  4. Vladimir Garagulya
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  5. mingya
    Member
    Posted 1 year ago #

    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

  6. Vladimir Garagulya
    Member
    Plugin Author

    Posted 1 year ago #

    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
    Conclusion:
    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic