Customer Area adds the concept of user groups with two of its add-ons: simple user groups in the “Additional owner types” add-on and managed user groups in the “Managed Groups” add-on. Sometimes, you would like to automatically add a user to a group when he registers.
You can include these simple snippets inside your theme’s functions.php file or inside your Customer Area theme’s cuar-functions.php file.
For “Additional owner types” user groups
function cuar_add_new_user_to_group( $new_user_id ) {
$destination_group_id = 123; // put the real group ID here
$group_addon = cuar_addon('user-group');
$group_addon->add_user_to_group( $new_user_id, $destination_group_id );
}
add_action( "user_register", "cuar_add_new_user_to_group" );
For the “Managed Groups” add-ons.
Please note that in this case, you can either add the user as a manager of the group or as a simple member (or both if you feel this is appropriate).
function cuar_add_new_user_to_managed_group( $new_user_id ) {
$destination_group_id = 123; // put the real group ID here
$is_manager = false; // set to true if you want that user to be a manager within that group
$is_member = true; // set to true if you want that user to be a simple member of that group
$group_addon = cuar_addon('managed-groups');
if ( $is_manager ) {
$group_addon->add_manager_to_group( $new_user_id, $destination_group_id );
}
if ( $is_member ) {
$group_addon->add_member_to_group( $new_user_id, $destination_group_id );
}
}
add_action( "user_register", "cuar_add_new_user_to_managed_group" );

