The MU forums have moved to WordPress.org

'If' statement: Has current user got admin privileges on this blog? (7 posts)

  1. hempsworth
    Member
    Posted 16 years ago #

    I'm looking for a way to code this:
    <?php
    if (user has admin privileges on this blog) {
    echo 'Show something';
    } else {
    echo 'Show something different';
    }
    ?>
    Any ideas?

  2. lunabyte
    Member
    Posted 16 years ago #

    you mean like...

    user_can('privilege')?

    or is it allowedTo? I think it's the first. I've been buried in SMF code for the past month so it's all blending together in my head.

  3. hempsworth
    Member
    Posted 16 years ago #

    Not quite, more like: user has access to admin panel, perhaps:

    user_role('admin')
    I know one exists, I just don't know the correct term.

  4. drmike
    Member
    Posted 16 years ago #

    I think the call is is_admin.

    edit: I can't find it right off though. Most of the checking is done with access levels. For example:

    current_user_can('edit_users')

  5. hempsworth
    Member
    Posted 16 years ago #

    I'll try with something like that, I guess if they are able to edit users they must have access to the admin panel.

  6. hempsworth
    Member
    Posted 16 years ago #

    What would I actually write after:

    <?php
    if

    Thanks

    Edit: Sorry, just tried it out and works great. Thanks both!

  7. lunabyte
    Member
    Posted 16 years ago #

    current_user_can, user_can, bah... whatever. :D

About this Topic

  • Started 16 years ago by hempsworth
  • Latest reply from lunabyte