How to check if currently in Wordpress Admin? How to check if currently in Wordpress Admin? wordpress wordpress

How to check if currently in Wordpress Admin?


Duh, this was too obvious. For some reason I was thinking this had to do with an admin user.if(is_admin()) { ...output my admin stuff....}

http://codex.wordpress.org/Function_Reference/is_admin


If you want to know whether current user IS ADMIN, then you should use this:

   $is_admin = current_user_can( 'manage_options' );

I got misguided by the above answer, so a little note to keep others from making the same mistake.


Note that is_admin() only works in the backend. For any part of the plugin that shows on the public website you need to use current_user_can().

if ( current_user_can( 'administrator' ) ) {  // your code goes here}