WordPress Frontend Check If Current User Is Administrator

Apparently the function is not defined at the point of calling your code ..so wrap the code of yours in to a function and hook it to the init.