The MU forums have moved to WordPress.org

when user creates blog they lose their role on the main blog (5 posts)

  1. circuit
    Member
    Posted 14 years ago #

    this is a new install integrated with bbpress.

    users sign up and are given contributor status to the main blog.

    as soon as they create their own blog, they lose all access to the main blog and their role becomes "- no role for this blog -".

    can anyone suggest why their roles are being reset in this way?

    this doesn't seem to happen for the site admin.

  2. circuit
    Member
    Posted 14 years ago #

    i tried adding this code as a plugin in mu-plugins as suggested elsewhere, but it doesn't work.

    <?php add_action( 'wpmu_new_user', 'ds_new_user_meta', 10, 1);
    function ds_new_user_meta($user_id) {
    			add_user_to_blog('1', $user_id, 'contributor');
    }
    ?>

    now, when a user signs up AND creates a blog, the blog is not created.

    in addition, if they they create the blog again, they lose their contributor status to the main blog (exactly as they would in my original scenario).

  3. circuit
    Member
    Posted 14 years ago #

    I advise everyone NOT to try the code above as i have completely screwed my roles/capabilities by doing so..

  4. circuit
    Member
    Posted 14 years ago #

    restored from backup. hooray. the original problem remains though. i've spent about three hours reading around it and i can't figure it out. could it be a buddypress conflict?

  5. dsader
    Member
    Posted 14 years ago #

    You want a plugin to add users to blog 1, when they create a blog. The add_action in the code you've got there only fires when a new user is created, then never again.

    The conflict may be the with the dashboard blog option in SiteAdmin-->Options.

    If left blank, the Dashboard blog is blog 1. So when a user without a blog creates a new blog, WPMU looks for membership in the dashboard blog and removes the user ... or some such cycle you've experienced.

    What I think is going on is that the parameter $blog id also needs to be in the plugn code you want so the user is placed in blog 1 when a blog is created - wpmu_new_blog - (as opposed to when a user is created, as you have there).

    The code I'd use looks like this, and I've added users, then blogs to verify that it works for me still:

    function ds_new_user_meta($blog_id, $user_id) {
    add_user_to_blog('1', $user_id, 'subscriber');
    }
    add_action( 'wpmu_new_blog', 'ds_new_user_meta', 10, 2 );

    Users that are members of blog 1 stay in blog 1 after creating another blog.

    Oh, I don't have an install with BuddyPress.

About this Topic