Can I add a CSS class to the body?

The reason this goes away is because when you switch to another user with User Switching you are actually getting logged in as that user, therefore you see exactly what the user will see. In your case it means the is-admin class isn’t present on the body because the user isn’t an admin.

If you do need this in place and you understand the consequences of making changes based on the user account that they switched from, then yes you can use the current_user_switched() function for this. Details here on this FAQ.


This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer