SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard ryanhellyer's Avatar
    Join Date
    Oct 2006
    Location
    New Zealand
    Posts
    2,323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    WordPress: How to determine if on admin page

    Any ideas how to determine if you are on an admin page or not? is_admin works fine for determining if the user is an administrator, but I need to figure out whether it is an admin page the users is on or not.

    Do any of you know a simple way to work this out? I thought there would be a simple 'WordPress conditional tag' for it but I can't find one.

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,608
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    Test if wp_admin is a part of the address. All of the admin pages are in that folder.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Wizard ryanhellyer's Avatar
    Join Date
    Oct 2006
    Location
    New Zealand
    Posts
    2,323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. I might pass on that though as it will confuse the heck out of anyone who uses wp_admin in the title of a random blog post. I need this for a plugin which is used by quite a few people who blog about WordPress so the chances of this happening isn't impossible.

  4. #4
    SitePoint Addict
    Join Date
    Mar 2006
    Posts
    367
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ryanhellyer View Post
    is_admin works fine for determining if the user is an administrator, but I need to figure out whether it is an admin page the users is on or not.
    is_admin should resolve to true whenever one is in the admin. It has nothing to do with a user's role directly. It just checks if 'WP_ADMIN' is defined which happens when any administration page is loaded.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •