Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 1 replies (of 1 total)

  • Thomas M
    Participant

    @webzunft

    The following code works for me:

    function automatic_group_membership( $user_id ) {
       if( ! $user_id ) { 
    	   return false;
       }
     
       groups_invite_user( array( 'user_id' => $user_id, 'group_id' => $group_id ) );
    }
    add_action( 'bp_core_activated_user', 'automatic_group_membership' );
    add_action( 'user_register', 'automatic_group_membership' );

    You need to replace $group_id with the ID of the group you want to assign users to.
    I have not tested the code when inviting members as a non-admin. That might be a limitation. There is an optional is_confirmed argument that can be submitted with groups_invite_users. Maybe, setting it to true helps in such cases.

Viewing 1 replies (of 1 total)
Skip to toolbar