Autocomplete on a custom field on the registration form no longer working
What you say suggests it's this line that's the issue:

 if ($_SERVER['HTTP_REFERER'] == url('user/register', array('absolute' =&gt; TRUE))){


so there's presumably some difference between the referrer URL and the one generated by the url() function. You might add lines above it to record the two values using watchdog: that would confirm you are reaching that point in the code and help diagnose the issue.