Contribution to community:
This is how I solved the issue (given that in TML > Moderation > “E-mail Confirmation” is choosen):
1. Insert this code in functions.php
function set_role_on_registration( $user_id ) {
if( isset($_POST['role']) )
{
$role = 'friends';
}
if ( in_array( $role, array( 'friends', 'guest' ) ) )
add_user_meta( $user_id, 'pending_role', $role );
}
add_action( 'tml_new_user_registered', 'set_role_on_registration' );
function set_role_on_activation( $user_id ) {
if ( $pending_role = get_user_meta( $user_id, 'pending_role', true ) ) {
if ( !in_array( $pending_role, array( 'friends', 'guest' ) ) )
return;
$user = new WP_User( $user_id );
$user->set_role( $pending_role );
unset( $user );
}
}
add_action( 'tml_new_user_activated', 'set_role_on_activation' );
2. Copy theme-my-login/templates/login-form.php to your current theme’s directory and rename it login-form-2.php
Create a new page titled “Login Form 2” and place in it the following shortcode: [theme-my-login login_template=”login-form-2.php”]
3. Edit file login-form-2.php and enter the following code:
<input type="hidden" name="role" value="friends" />
just under line:
<p class="submit">
4. In front-end, role-based registration is made through page “Login Form 2”
Cheers