Right click the hat in your inventory and select attach to, then use your chin ( if you use your nose you can not wear glasses) and attach it. Then right click the hat on your avatar and adjust it until it is in the correct position and rotation on your head. Viola, hat and hair at the same time. Since it remembers the attachment point, you should only have to do this once, from then on, you just wear it.