Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if currently in Wordpress Admin?

I am creating my first plugin and have a single function that controls the output. This function has different output based on whether or not it is being viewed from within the WordPress admin vs. the frontend. Is there any way to easily test whether or not my function is being triggered from within admin vs the frontend?

I've tried conditionally checking the query string against the name of my plugin "page" name but it seems to fail on some servers/installs.

Thanks

like image 969
Matt Avatar asked Nov 08 '10 21:11

Matt


People also ask

How do I know if I am logged in as admin WordPress?

How to check whether a user is administrator or not. To check if the currently logged in user is an administrator, use the current_user_can function. To check if a user is an administrator, you can specify the capability as an argument of current_user_can function (e.g. manage_options).

How do I find my WordPress admin?

On your browser's address bar, search for your domain name with /wp-admin or /wp-login. php at the end, e.g., example.com/wp-admin or example.com/wp-login.php. Type in your WordPress Username or Email Address and Password.

Does WordPress have a default admin account?

By default WordPress creates an administrator user account named admin. Using the default Admin WordPress Account, hackers can easily launch a brute force attack against it.


1 Answers

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

like image 113
Matt Avatar answered Nov 09 '22 19:11

Matt