Replace everything you have here with the following:
Lua Code:
local f=CreateFrame("frame")
f:RegisterEvent("PLAYER_LOGIN")
f.update=function(frame)
if frame and frame.unit=="player" and frame.portrait then
if frame.onHateList then
for i=1,GetNumShapeshiftForms() do
local _,active,_,spellid=GetShapeshiftFormInfo(i)
local _,_,icon=GetSpellInfo(spellid)
if active and icon then
SetPortraitToTexture(frame.portrait,icon)
return
end
end
end
SetPortraitTexture(frame.portrait,"player")
end
end
f:SetScript("OnEvent",function(self,event)
if event=="PLAYER_LOGIN" then
local _,class=UnitClass("player")
if class~="WARRIOR" then return end
self:RegisterEvent("PLAYER_REGEN_DISABLED")
self:RegisterEvent("PLAYER_REGEN_ENABLED")
self:RegisterEvent("UPDATE_SHAPESHIFT_FORM")
hooksecurefunc("UnitFramePortrait_Update",self.update)
end
self.update(PlayerFrame)
end)