Remove unnecessary variables and function calls in follow_post_usergroups and force usergroup IDs to be integers

$user_group->term_id returns an ID of the term as a string and when wp_set_object_terms is run it creates a new group with that ID name instead of finding the term. The fix is to force each of the $usergroup values to be an integer.