Manually add users to a membership through a php function?

Hi,

Is there any way to call a function in php to manually add an user to a membership (a free one)?

I know the plugin handles this automatically when using the registration form, but i'm using the form by theme my login because it offers registration verification, however this way users aren't added to the basic membership automatically.