How to allow other roles to edit M2 settings

If, like me, you are using a custom role for subsite owners or administrators then you will have lots of issues with M2 as it needs Administrator account to save settings and access all features.

M2 has its own is_admin function that is used in a lot of places and if it returns false most stuff doesn't work.

Luckily M2 is really nicely coded and it is simple to get around this. There is a hook "ms_model_member_is_admin_user" that you can use to filter the return value of is_admin().

The simplest way I found to do was add my own custom capability and then allow that as M2 admin. add this code to a must-use plugin.

add_filter('ms_model_member_is_admin_user', 'my_m2_custom_admin',10,3);

function my_m2_custom_admin($is_admin, $user_id, $capability)

	if (current_user_can( 'your_custom_cap' ))
		$is_admin = true;

	return $is_admin;

This will allow any role that has the capability.

One thing to note is that the "Administrator" role will still be able to edit the settings. If you want to disable this M2 has convenient constant or filter you can use.

Just add to wp-config.php

define( 'MS_ADMIN_CAPABILITY', 'your_custom_cap' );

or use filter "ms_admin_user_capability" and then if the Administrator doesnt have the capability then they wont be able to edit it. (super admin will always be able to do everything)

Anyway, this took me a while to work out so hopefully this will save someone else some time.