[resolved] Automatically Be Added as SuperAdmin to User Created Multisites (4 posts)

  1. foxymcfox
    Posted 3 years ago #

    Is there any way that I can automatically be added as a user and SuperAdmin of user-created multi-sites.

    Basically, I want the site, once created to be listed under "My Sites."

    Any ideas? Thanks.


  2. David Sader
    Posted 3 years ago #

    Here's a code snippet in a file in my "mu-plugins"

    add_action( 'wpmu_new_blog', 'ds_new_user_meta', 10, 2 );
    function ds_new_user_meta($blog_id, $user_id) {
    add_user_to_blog($blog_id, '1', 'administrator' ); // adds SuperAdmin to the blog a user just created

    The '1' is my SuperAdmin ID, but you may have other ID # as SuperAdmin.

  3. foxymcfox
    Posted 3 years ago #

    So, did you just make this a standalone, single-function plugin, or did you tag it on to another one of your plugins? I'm just trying to understand your process.

    Thanks for the code! It's one of those things that seems so obvious once you actually see it.

    I owe you a virtual drink! haha


    EDIT: Since I didn't make it clear here, I put that code in a plugin wrapper, uploaded it, activated it ONLY on the base URL, (Not network activated) and it works perfectly...hence me owing you an e-Drink. I was just curious about your implementation.

  4. David Sader
    Posted 3 years ago #

    My process: I have a "mu-plugins" folder in wp-content. I add snippets such as this in its own *.php file and away it goes - no fancy plugin wrapper needed.

    I spend more time fiddling/testing/tuning via ftp in the "mu-plugins" - my preference.

Topic Closed

This topic has been closed to new replies.

About this Topic