I have a need to create a Team Control Role to match a website when the website is added to MainWP. Is there an action available to accomplish this?
Hey @webdiner
Can you please try this action:
add_action('mainwp_added_new_site', 'mycustom_add_roll_mainwp_added_new_site', 10, 2);
function mycustom_add_roll_mainwp_added_new_site( $site_id, $website ){
if( class_exists('MainWP_Team_Control_Utility') ){
$role_name = 'Role for site ' . $site_id ;
$role_name_id = MainWP_Team_Control_Utility::gen_role_id( $role_name );
$result = MainWP_Team_Control_Role::get_instance()->add_new_role( $role_name, $role_name_id );
if ( is_array( $result ) && !empty( $result['success'] ) ) {
$example_role_caps = array(
'dashboard' => array(
'edit_sites' => 1,
'delete_sites' => 1,
'access_individual_dashboard' => 1,
'access_wpadmin_on_child_sites' => 1,
'manage_security_issues' => 1,
'test_connection' => 1,
'manage_clients' => 1,
'install_plugins' => 1,
'delete_plugins' => 1,
'activate_deactivate_plugins' => 1,
'install_themes' => 1,
'delete_themes' => 1,
'activate_themes' => 1,
'update_wordpress' => 1,
'update_plugins' => 1,
'update_themes' => 1,
'update_translations' => 1
),
'extension' => array(
'mainwp-domain-monitor-extension' => 1
),
'site' => array(
$site_id => 1,
),
'group' => array(),
);
$site_role = array(
'role_name' => $role_name,
'role_description' => "Role for site",
'type' => 0,
'role_name_id' => $role_name_id,
'role_capabilities' => base64_encode( serialize( $example_role_caps ) ),
);
$added = MainWP_Team_Control_DB::get_instance()->add_role( $site_role );
if( $added ) {
// success.
}
}
}
}
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.