BuddyDev

Adding Users to the Blog on which they Register in A BuddyPress & WordPress Multisite based Social network

Are you using BuddyPress with WordPress Multisite? Are you facing the problem that when a user registers he/she appear in the Network Admin Users list but not in your Main site/Sub site's user list. Well, I have seen this issue and here is a solution.

You can put the following code in your bp-custom.php and It will add a user to the blog on which they register (In case of BuddyPress Multi Network, BP_ENABLE_MULTIBLOG mode) or to the main site with proper role.

When the user account is activated, It adds the user to the blog on which they have activated their account.

Have fun & wish you all  Merry Christmas friends 🙂

5 Responses to Adding Users to the Blog on which they Register in A BuddyPress & WordPress Multisite based Social network

  • Hi
    Is it possible set default role not "Subscriber" but for example "Contributor" without plugins for Multisite?

    • Hi Roman,
      Thank you for asking.
      Just change this line
      [sourcecode language="php"]
      add_user_to_blog( $blog_id, $user_id, get_option('default_role') );
      [/sourcecode]
      to
      [sourcecode language="php"]
      add_user_to_blog( $blog_id, 'contributor' );
      [/sourcecode]

      and that will be done.

      hope that helps.

  • HI Brajesh

    am not using activation emails by using plugin BP Disable Activation. How do i add the user to the blog then?

    Kindly let me know

    Thanks
    Vishal

    • Hi Vishal,
      My apologies for delayed reply.
      You should try adding on this hook 'bp_auto_activate_after_login'

  • Thanks for your reply. highly appreciated. How do i excatly add bp_auto_activate_after_login in the code? tried googling but bp_auto_activate_after_login is not referenced anywhere else. i tried this but didnt work out:

    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 ) )
    bp_auto_activate_after_login( $blog_id, $user_id, get_option('default_role') );

    }