How to Change The default Role when new site is added to a mulitisite networks

Whenever we create a new site from the Multi site Network it automatically add administrate role to that user that user has full access to network admin .
Suppose if we want to change the Admin role to Author here what you need to do. you need to place the code in an function.php

function wpdadd_admin_to_author($blog_id, $user_id) {
    switch_to_blog($blog_id);
    $user = new WP_User($user_id);
    if ($user->exists()) {
      $user->set_role('author');
    }  
    restore_current_blog();
  }
 
  add_action( 'wpmu_new_blog', 'wpdadd_admin_to_author', 10, 2 );

Add a Comment

Your email address will not be published. Required fields are marked *

4 + nineteen =