The MU forums have moved to WordPress.org

Replace is_site_admin functionality with WP_Role based capabilities (7 posts)

  1. dcneiner
    Member
    Posted 14 years ago #

    So, I was digging around in the WPMU core today (and have been in the past as well), and discovered that instead of a traditional has_cap() call, a WPMU only function (is_site_admin) is used throughout the code.

    My problem with it is this, it makes it impossible to override some features without hacking the core (which is a No, No, in my book). Using the same base functionality (is username in array of site admins), a dynamic "site_admin" role would be all that is needed to change over the functionality. Basically the "site_admin" role would not exist in the database, but as a "ghost role" if you will, only applied to users in the site admins array on WP load. Then, instead of is_site_admin() we could be more specific like: has_cap('add_users_without_confirmation').

    I think this is important, because then all modifications could be contained in a plugin, and give certain users additional power w/o granting them full site_admin status on a MU installation.

    Was there a specific reason it was done this way to begin with? Finally, I am totally new to the forums or the dev team on MU, so forgive me if this is posted in the wrong area... if I should be barking up a different tree, let me know!

    I would be willing to make the changes and send a diff, if it is something that would be considered by the MU team.

  2. cafespain
    Member
    Posted 14 years ago #

    My problem with it is this, it makes it impossible to override some features without hacking the core

    It's very easy to override ANY site_admin related features without hacking the core.

  3. dcneiner
    Member
    Posted 14 years ago #

    Perhaps a case in point: I am using WPMU to power multiple sites, not to give users their own blog per se.

    So I want blog administrators to be able to edit the users on their blog, and to add new contributors (sending them an email with their password) without sending the confirmation email first.

    You can only do that (and only see the option) if you are a site admin, period. There is no way to override that w/o hacking the code, or duplicating the entire functionality into a separate plugin (which isn't easy).

    I mean, the code is pretty straight forward: !is_site_admin() ... wp_die(). And is_site_admin doesn't call any filters or hooks, just checks if the user-name is present in the array of approved usernames.

    Am I missing something?

  4. cafespain
    Member
    Posted 14 years ago #

    There is no way to override that w/o hacking the code, or duplicating the entire functionality into a separate plugin (which isn't easy).

    :) Yes there is, you need to look more into the filters that are called for, and around, the is_site_admin function.

    You can pretty much override the entire function and have it return whatever you want at any point, including making normal admin users have "super-powers" for certain operations / pages.

    blogs.mu has thousands of "site_admin" users that have some site_admin abilities removed and some extra ones added and not a single line of the core MU was touched.

    WordPress MU is an extremely powerful and customisable piece of software. You just need to know were to look and what to hook into / filter.

  5. dcneiner
    Member
    Posted 14 years ago #

    Awesome, thanks! I will look deeper tonight, and hopefully undo my earlier changes. I really appreciate it. I still think Roles and Capabilities would make sense, but that was secondary to my thought that I had to edit core files.

    I really appreciate it!

  6. cafespain
    Member
    Posted 14 years ago #

    I think it would be a useful addition as well to be honest, but until then :)

  7. andrea_r
    Moderator
    Posted 14 years ago #

    They're re-doing the Roles and Capabilities in WP, which will of course transfer to MU.
    http://www.wptavern.com/forum/general-wordpress/699-new-way-doing-user-roles-capabilities.html

    No idea what that means for Site Admins yet, but since the merge is upcoming, I'm sure they're thinking of something.

About this Topic

  • Started 14 years ago by dcneiner
  • Latest reply from andrea_r