Okay I have created a new enrollment key option in request membership form.
The problem is that where should I add check if enrollment key is true that user auto join group without asking from admin.
I have some code for auto join i think it will work but where should I add it.
if($enrollment_key == 'xxx'){
if ( bp_groups_auto_join() && bp_current_user_can( 'bp_moderate' ) && 'key' $bp->groups->current_group->status && !groups_is_user_member( bp_loggedin_user_id(),$bp->groups->current_group->id ) ) {
groups_join_group( $bp->groups->current_group->id, bp_loggedin_user_id() );
}
}