BuddyDev

Search

[Resolved] New code request for adding new users to subsite users and not main site's users

  • Participant
    Level: Initiated
    Posts: 5
    Tom on #760

    Brajesh made me a code snippet some time ago.

    It was made to add a new registering user that is registering to a subsite be added to that subsite’s users and not the main sites user’s.
    When using BuddyPress Multi Network.

    For example: If you have mainsite.com and you have someone that signs up @mainsite.com and creates a new blog in with Multisite.

    This new user gets subsite1.mainsite.com

    Then subsite1 has buddypress activated locally on subsite1 along with BuddyPress Multi Network so they can have a private buddypress network just for subsite1’s users.

    So when the admin for subsite1 get’s users to sign up to their subsite, he/she wants those users to be a member of the subsite only and not part of the main sites users.

    For a little while this was possible due to Brajesh writing a wonderful little snippet that mad this possible. Now this snippet has stopped working. Now when a user signs up to the subsite, that user is not added to any user base. Neither the main site or subsite.

    Below is the depreciated snippet that Brajesh wrote:

    —————————————————————————
    Please put this code in your bp-custom.php

    add_action( 'bp_core_activated_user', 'bpdev_add_user_to_registering_blog');

    function bpdev_add_user_to_registering_blog( $user_id ) {
    $blog_id = get_current_blog_id();
    if( !is_user_member_of_blog($user_id, $blog_id ) )
    add_user_to_blog( $blog_id, $user_id, get_option('default_role') );

    }

    That will add a user to the registering blog when he activates his/her account.

    ----------------------------------------

    Any help would be greatly appreciated.

  • Keymaster
    (BuddyDev Team)
    Posts: 22201
    Brajesh Singh on #765

    Hi Tom,
    Thank you for asking.

    I will look into it on Monday and will get back to you. Need to test it on Multinetwork setup.

    Is there any other information that you feel can help? Like when did it started misbehaving after upgrading WordPress or installing some plugin etc? Also, what is your current WordPress & BuddyPress version.

  • Participant
    Level: Initiated
    Posts: 5
    Tom on #775

    Brajesh, please disregard my question. I was a little quick to pull the alarm.

    There was nothing wrong with your code and everything is as it should be (knock on wood).

    I’m a little embarrassed that I even suspected.

    Thanks again for being eager to help. You are the coolest dude on the web.

The topic ‘ [Resolved] New code request for adding new users to subsite users and not main site's users’ is closed to new replies.

This topic is: resolved