9

In my application, i have one form. Now if user is in front end i want to display the title but if he is in back end i do not want to display it.

I do not want to check it based on user role.

16

Use is_admin(). It checks if you're viewing an Admin page, means the backend.

  • will it work for other user like subscriber ? – Ajay Patel Mar 13 '12 at 5:42
  • Yep. It works for all roles. – Rutwick Gangurde Mar 13 '12 at 5:42
  • How about loading a script on a specific admin page? – AlxVallejo Dec 27 '12 at 1:01
  • The action hook admin_print_scripts is meant to do that. – Rutwick Gangurde Dec 27 '12 at 5:09
  • 2
    Of note, an ajax request will make this return TRUE. Also, right in the documentation it says that this is not meant to be used as a security check. – Dez Dec 12 '17 at 16:54
9

Use is_admin() to check if the the current page is an administration page. Despite its name this is not a user role check.

  • will it work for other user like subscriber ? – Ajay Patel Mar 13 '12 at 5:42
  • 1
    Read the Codex page: is_admin() returns always FALSE on front end. No matter which role the user has. – fuxia Mar 13 '12 at 5:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.