Kriesi.at – new media design

Frontend Admin Menu in Wordpress

Here is a short tutorial on how to create an additional Wordpress menu that only shows up if a user is logged in. I use this technique to create admin front end interface menus for the most used tasks: writing and editing posts and pages, editing the current post , a direct link to the "manage" Section of the Wordpress admin Interface etc.

Here are 2 screenshots of the right top of my header graphic. The first one is what everybody else sees.
And this is what I see as long as I am logged in:
This is easily done with the Wordpress function current_user_can()

As a parameter for the function you just have to add the expected user level and wrap the whole function call in an if statement.

<?php
        if (current_user_can('level_10')){
        /*do something*/
        }
?>

The /*do something*/ code would now only be added/executed if the user has a status of level 10, thus is an administrator. To get more information on User Levels check the Wordpress Documentation.
Here is a short list of the user capabilities, just in case you don't really care and only want to add a menue for a specific user group:

  • Subscriber : level_0
  • Contributor: level_1
  • Author: level_2
  • Editor: level_3 – level_7
  • Administrator: level_8 – level_10

Last but not least a short example of how an admin menu could look like:

<?php
    if (current_user_can('level_10')){ ?>
        <ul class="admin_box">
            <?php wp_register(); ?>
            <li><?php wp_loginout(); ?></li>
            <li><a href="<?php echo get_option('home'); ?>/wp-admin/post-new.php">Write new Post</a></li>
            <li><a href="<?php echo get_option('home'); ?>/wp-admin/page-new.php">Write new Page</a></li>
            <li>do something</li>
            <li>do something</li>
        </ul>
<?php }?>

Have fun creating your own user related menus ;)

Responses to “Frontend Admin Menu in Wordpress”

Trackbacks

  1. Skylog » Blog Archive » links for 2008-05-20
  2. WordPress Studios » Admin login on your front page
  3. 在首页加入一些管理员链接 - Neversay
  4. WP Foundations » Admin login on your front page
  5. Test Track
  6. Added some menu functions | davidedwardsphotos.com
  7. links for 2009-07-02 | BlueWave Media

Leave a Reply