add administrator to multiple sites

Is there a plug in that i can add one administrator to multiple sites? I am adding one site at a time. Looking for an efficient way.

  • Ash

    Hello @Adam Kayden

    I hope you are well today and thanks for asking the question.

    Please try the following code:

    <?php
    $blogs = array( 12, 22, 41, 47, 51, 55 );
    $user_id = 5;
    foreach( $blogs as $blog ){
        add_user_to_blog( $blog, $user_id, 'administrator' );
    }

    You need to give the blog IDs in $blogs array and the user ID of the administrator n $user_id variable.

    You can add those codes as mu-plugins. To use mu-plugins, go to /wp-content/ and find the folder with name 'mu-plugins'. If there is no folder in that name, then create a folder, name it 'mu-plugins', create a file inside that, give any name you like and paste the code in there. You don't need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

    Then run the site once. And after checking, remove the code, you won't need that anymore.

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers
    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.