get USER ID in functions.php using user_register action

You are giving $wpdb->get_results a string for its second parameter. It should be a constant– ARRAY_N— meaning you need to remove the quotes

$getunion = $wpdb->get_results(
  "SELECT value from wp_bp_xprofile_data where user_id = $getid AND field_id = 4", 
  ARRAY_N
);

Since you claim it works in the second instance, I am assuming $wpdb compensates, but I haven’t verified that. Thought I’d mention it.

I think your problem is here:

    $user = new WP_User($user_id);
    $user_login = stripslashes($user->user_login);
    $user_email = stripslashes($user->user_email);
    $getid      = $user->ID;

You have your user ID coming into the function as $user_id. I don’t know why you are creating another user. I believe that replacing those four lines with the following with sort things out.

    $user = get_user_by('id',$user_id);
    $user_login = stripslashes($user->user_login);
    $user_email = stripslashes($user->user_email);
    // $getid      = $user->ID; // you already have the user ID -> $user_id; use that below or change this line to
    $getid = $user_id; // if you must