well i suppose you get the error when you had to login..because when you login you shortly (during redirection) have the login.php that has VB_AREA == 'forum' while the admincp has VB_AREA == 'AdminCP'. IMHO, I think, this has nothing to do with vbgallery.
You should get the error also if you only had:
if(VB_AREA == 'forum')
so I would test without the vbgallery part.. if it runs then just add OR VB_AREA == 'vBGallery'
Thats all i can say, as I never used vbadvanced and do not know how they do their check.