WordPress.org

Ready to get started?Download WordPress

Forums

Theme switcher only for Admin? (4 posts)

  1. Kerim
    Member
    Posted 9 years ago #

    I'm trying to wrap the Theme switcher plugin so that only the admin can see it. That way I can work on a backup theme while my site's regular viewers see the regular theme I have set as default. However, I don't seem to have the PHP code right. Can anyone help?

    Here is what I have:

    <?php global $user_level; if ($user_level > 8) { ?>
    <ul>
    <h2>Theme Switcher</h2>
    <li>
    <?php get_theme_switcher() ?>
    </li>
    </ul>
    <?php } ?>

    If I remove the PHP code the theme switcher shows up just fine. With the PHP code I never see anything. I even tried adding an "echo $user_level;" command, but that didn't do anything either. What am I missing?

  2. Joshua Sigar
    Member
    Posted 9 years ago #

  3. Kafkaesqui

    Posted 9 years ago #

    Try this:

    <?php get_currentuserinfo(); if ($user_level > 8) { ?>

  4. Kerim
    Member
    Posted 9 years ago #

    alphaoide: I had tried that and it disabled my entire WP install!!! Also, it doesn't offer such a nice menu, or persistent caching across sessions.

    Kafkaesqui: Thanks! You put me on the right track. This works:

    <?php get_currentuserinfo(); global $user_level; if ($user_level > 8) { ?>

    Just what I wanted!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.