Skip to content
This repository has been archived by the owner on Sep 27, 2022. It is now read-only.

Multisite - sync roles #144

Open
alexis-magina opened this issue Jul 23, 2017 · 2 comments
Open

Multisite - sync roles #144

alexis-magina opened this issue Jul 23, 2017 · 2 comments

Comments

@alexis-magina
Copy link

alexis-magina commented Jul 23, 2017

Hello,

I use your plugin on a WP Multisite and I noticed that capabilities modifications applied on one site are not reported on all network's sites.
This is good to not "force" syncing roles : we could want to have differents roles settings accross all networks sites, but, I think - and this is my case - that we could also prefer to sync this setting to not re-apply manually capabilities for each network site.
I use your hook members_role_updated to loop on each site and register option.
I think it could be good to add it on your plugin, with a checkbox on settings page to allow/disallow this synchonization.

add_action('members_role_updated', 'sync_members_roles', 10, 1);
function sync_members_roles($role){
global $wp_roles;
$current_roles = $wp_roles->roles;
// Loop all sites except current :
$sites = get_sites( array( 'site__not_in' => array( get_current_blog_id() ) ) );
foreach ( $sites as $site ) {
switch_to_blog( $site->blog_id );
global $wpdb;
$option_name = $wpdb->prefix . 'user_roles';
update_option( $option_name, $current_roles );
}
restore_current_blog();
}

@justintadlock
Copy link
Owner

One thing you'd definitely need there is an is_super_admin() check. That code might be all right for a one-off site that you're in control of though.

Ideally, we'd need something like a setting in the network admin. This shouldn't be a setting that's applied to individual blogs in the network.

Moreover, it'd probably be a better idea to have a role management system within the network admin itself for super admins to control. Some items to consider:

  • Should be able to apply the role to all blogs in the network or, perhaps, just some blogs.
  • Super admin should have the ability to create both Editable and Uneditable roles.
    • Editable roles can be edited or deleted on a per-blog basis.
    • Uneditable roles cannot be edited or deleted.

@guillaumemolter
Copy link

+1 for multisite settings.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants