WordPress.org

Ready to get started?Download WordPress

Forums

User 1 (Admin) added to all blogs (3 posts)

  1. Xen
    Member
    Posted 8 years ago #

    Hey WPMU users,

    I spent hours trawling these forums for the ability to add myself (the default user) as admin on all blogs on the system, I know it's not neccesary because I have the power on all blogs but it's an added deterrent for possible spammers if the site admin is registered on their blog... It's also quite useful to keep track of all the blogs on the system by using

    <?php
    $blogs = get_blogs_of_user(1);
    if ( ! empty($blogs) ) foreach ( $blogs as $blog ) {
    echo "<li><a href='" . $blog->domain . $blog->path . "'>" . $blog->domain . $blog->path . "</a></li>";
    }
    ?>

    So I took it upon myself to make it so that when a new blog is created, it adds the admin user to that blog! and just after I did this I thought....

    Why not allow other people to do this?

    So here's how!

    OPEN:

    wp-includes/wpmu-functions.php

    FIND:

    function wpmu_create_blog($domain, $path, $title, $user_id, $meta = '', $site_id = 1) {
    $domain = addslashes( $domain );
    $title = addslashes( $title );
    $user_id = (int) $user_id;'

    Then, A little bit further down FIND:

    add_user_to_blog($blog_id, $user_id, 'administrator');

    after this line ADD:

    add_user_to_blog($blog_id, X, 'administrator');`

    where X is the userid of the user you wish to add, this can be repeated if you have multiple site admins ^_^

    Enjoy!

    Note that neither myself nor wordpress are responsible for the effects of this "hack". You utilise it at your own risk! By using this solution you agree to indemnify all parties against any legal action arising!

  2. moshu
    Member
    Posted 8 years ago #

    You are in the wrong forum.
    We don't support WP MU. They have their own forum.
    http://mu.wordpress.org/forums/

  3. Xen
    Member
    Posted 8 years ago #

    lol, that's the problem with having such similar looking websites :-p

    go ahead and remove the thread, i've re-posted :-D

Topic Closed

This topic has been closed to new replies.

About this Topic