Simply remove: $CustomField1 = $user_profile[20]
Your code set a variable and then checks to see if it equals nothing? Either move that line to the beginning to serve as a default if code later on sets it. Or, kill it as I suggest and let the if/else statements set it accordingly. It's the positioning that matters if your code is used (btw, add a semi-colon on the end of that 1st line).
I always advise setting a default at the beginning of source to compensate for any missing future file or user input errors/conditions. Later on, check for values and set conditionally. If no conditions are met, the value is the default. Your else condition essentially does that, so either method will work, but your method obviously cannot.
When you define defaults for variables, think ahead as to possible mistakes. The default should always be a "fallback" setting if literally, all else fails. You can even use defaults to see if other routines failed. Defaults are good, if used properly. But positioning is the key.
-Jim