Programmatically Add User to Members


On my site I currently have the ability to enter a activation code and then access a Gravityforms/BuddyPress sign-up form. When a valid code is entered into a box then the user is allowed to register for my site. This process however does not tie in to Membership 2 Pro at the moment, is there a hook and function I can call to add the user to a specific membership type or types programatically? Adding the users manually in the Admin is not an option.