How do I create a private forum with just an invitation code

I wanted some help to create this function, idk if I can or something but I rlly want to.
here’s a screenshot for example: