Please, remove the $wgUser and move it to the place where the variables for the template are set.