drupal removes language key from variables in templates
Once you are logged in, another language is requested and the 'und' key no longer works:
https://www.deeson.co.uk/labs/programatically-access-field-data-using-entitymetadatawrapper-drupal
Try replacing your use of $vars['und'][0]['value'] with Entity metadata wrappers. More examples here: https://www.drupal.org/documentation/entity-metadata-wrappers