• Resolved jordanwebdev

    (@jordanwebdev)


    I have a filter that adds an is-admin class if the user has administrator capabilities, but this goes away on user switch to a non-administrator. Is there any way I can keep it? Does a switched user have unique capabilities I can check for?

Viewing 1 replies (of 1 total)
  • Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    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.

Viewing 1 replies (of 1 total)
  • The topic ‘Can I add a CSS class to the body?’ is closed to new replies.