How to make Super Admin automatically a user for each new blog.

Hi,
When a new blog is created on my multi-site the Super Admin is not automatically a user of that site. Is this the way multi-site usually functions or have I altered it by adding code to make the new user a default to a different role than usual. I am using New Blog Template but not copying over the users. If I have the Super Admin users on the template site and copy the users over in a new blog then the new user also ends up with Admin rights.

I'm thinking maybe I could change this code.
`<?php
function ds_new_user_meta($blog_id, $user_id) {
add_user_to_blog($blog_id, $user_id, 'shopowner' );
}
add_action( 'wpmu_new_blog', 'ds_new_user_meta', 10, 3 );
?>`
so that it also adds the multi-site super-admin users as users to the new blog?

Nat.

  • Tyler Postle
    • CGO

    Hey Nat,

    Hope you're doing well today and thanks for your question!

    Yes, this is default multisite behaviour. The super admin will have access to ALL sites, but only ones you create or add yourself to will show up in the "My sites" dropdown. The rest you can find via: My Sites > Network admin > Sites.

    Adding yourself with the New Blog Templates is a good idea then you could also try out User Role Editor and network activate it then set a default role for new user - that could be one solution to your issue.

    OR

    Multisite User manager could also come in handy as it allows you to set the default role too. Although, may not apply to new sites.

    I'm thinking that changing the default user role may be an easier way to go about this than automatically adding the super admin. I think the user would still have admin capabilities that way. Let me know what you think Nat!

    All the best,
    Tyler

  • Natalie
    • Site Builder, Child of Zeus

    Hi,
    I was finding it difficult to figure out how to make the new user default to a 'shop owner' role but have the Super Admins on my site added to the site in an admin role. When I used the New Blog Template to add the super admins to new sites it seemed to make the new user an admin too. So I did this and it seems to be working okay.

    <?php
    function ds_new_user_meta($blog_id, $user_id) {
    add_user_to_blog($blog_id, $user_id, 'shopowner' );
    add_user_to_blog($blog_id, '1', 'webmaster' );
    }
    add_action( 'wpmu_new_blog', 'ds_new_user_meta', 10, 3 );

    Nat.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.