Added a few lines to check if the user is logged in before performing admin actions