15

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.

26

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

6
  • will it work for other user like subscriber ?
    – Ajay Patel
    Mar 13 '12 at 5:42
  • Yep. It works for all roles. 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. Dec 27 '12 at 5:09
  • 4
    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. Dec 12 '17 at 16:54
15

Use is_admin() to check if the the current page is an administration page. Despite its name this is not a user role check. It returns always FALSE on front end, no matter what role the user has.

0

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.