User Role Editor
[resolved] WordPress 3.x.x Multisite bug (with details) (6 posts)

  1. FlashUK
    Posted 4 years ago #


    This seems to be a long standing issue that we have discovered using "User Role Editor" and WP Multisite.

    The issue we had was that Editors could not see the "Author" dropdown menu. At first we thought it was a problem when we upgraded WordPress - but actually tracked down to a particular block of code:
    File: user-role-editor.php Line: 150

    // add where criteria to exclude users with 'Administrator' role from users list
    function ure_exclude_superadmins($user_query) {
      global $wpdb;
      // get user_id of users with 'Administrator' role
      $tableName = defined('CUSTOM_USER_META_TABLE') ? CUSTOM_USER_META_TABLE : $wpdb->usermeta;
      $meta_key = $wpdb->base_prefix.'capabilities';
      $admin_role_key = '%"administrator"%';
      $query = "select user_id
                  from $tableName
                  where meta_key='$meta_key' and meta_value like '$admin_role_key'";
      $ids = implode(',', $ids_arr);
      $user_query->query_where .= " AND $wpdb->users.ID NOT IN ($ids)";
    // end of ure_exclude_superadmins()

    The problem with this code is the query it spits out:

    string 'select user_id
                  from wp_usermeta
                  where meta_key='wp_capabilities' and meta_value like '%"administrator"%'' (length=132)

    With Multisite, users capabilities are stored under "wp_blogid_capabilities" which is not taken into account, hence why it fails.

    Unfortunately left untreated spits out SQL errors in the backend.

    WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ORDER BY display_name ASC' at line 1 for query SELECT wp_users.ID,wp_users.display_name FROM wp_users INNER JOIN wp_usermeta ON (wp_users.ID = wp_usermeta.user_id) WHERE 1=1 AND ( (wp_usermeta.meta_key = 'wp_38_user_level' AND CAST(wp_usermeta.meta_value AS CHAR) != '0') ) AND wp_users.ID NOT IN () ORDER BY display_name ASC  made by include, do_meta_boxes, call_user_func, post_author_meta_box, wp_dropdown_users, get_users, WP_User_Query->__construct, WP_User_Query->query

    There is a fix for this, just amend your $meta_key to along the lines of:

    if (is_multisite()) {
        $meta_key = $wpdb->prefix.'capabilities';
      } else {
        $meta_key = $wpdb->base_prefix.'capabilities';

    Would appreciate it if you would put this in your next release. Thank you :)


  2. Vladimir Garagulya
    Plugin Author

    Posted 4 years ago #


    Thanks for your help and for so deep and detailed investigation of this issue.
    I will re-check what I really wished to achieve using 'base_prefix' instead of 'prefix' (which has the difference, I know) and return with my decision. Bug should be fixed ASAP anyway.

  3. merkin51
    Posted 4 years ago #

    This is all a bit above my head... will this fix my problem where Admins can't see the user list on the root network blog?

  4. Vladimir Garagulya
    Plugin Author

    Posted 4 years ago #

    I did not reproduce this error on my test site. But this update should fix it, as it takes this bug into account.

    It would be good, if you help me test the updated 3.5.1 version of User Role Editor plugin before I publish here. It is available from this link

  5. FlashUK
    Posted 4 years ago #

    I would love to help but I can see there is a lot of changes from our version control.

    I am already on deadline for a project and can't spare any time.

    To reproduce the problem you should:
    * Create an Editor account and another test editor account
    * Use Multisite and create a blog
    * Assign those users to the blog so there is multiple authors
    * Add/Edit post and show "Authors" dropdown (enable it through Screen Options)

    You will notice that if you logged in as an Admin, you can see the dropdown. If you are an Editor, you cannot.

  6. Vladimir Garagulya
    Plugin Author

    Posted 4 years ago #

    Thanks. I reporduced that.
    Yes, I confirm, this bug is fixed with 3.5.1 update. I will wait 1-2 day for messages from others who reported about problems with version 3.5 and publish fixed one.

    Btw, the simple workaround for that bug - you could assign at least to one user of your root blog the Administrator role.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • User Role Editor
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic