Jump to content

[SOLVED] Quick navbar if/else statement help


Recommended Posts

Hey everyone,

 

I would like to make a PHP if else statement so that if a user is NOT logged in it shows a "Login" button, and a "Register" button.

 

When they login the "Register" disappears, and the "Login" becomes "Logout"

 

And if someone is an Admin, for an "Admin" button to be added.

 

Here is my current navbar code:

 

<div class='capsule'>
    <a href='feed:<?php bloginfo('comments_rss2_url'); ?>'>
    <img border='0' align='top' alt='Comments RSS'
        src='<?php print bloginfo('template_directory') . "/images/rss-icon.gif"; ?>'>
    <span title='Subscribe to the RSS feed for the comments on this site'>Comments</span>
    </a>
    </div>

    <div class='capsule'>
    <a href='feed:<?php bloginfo("rss2_url"); ?>'>
    <img border='0' align='top' alt='Site RSS'
        src='<?php print bloginfo('template_directory') . "/images/rss-icon.gif"; ?>'>
    <span title='Subscribe to the RSS feed for the posts on this site'>Site</span>
    </a>
    </div>

    <?php if( $options['showloginout'] == 1 ) { ?>
    <div class='capsule'>
    <?php wp_loginout(); ?>
    </div>
    <?php } ?>

    <div class='capsule'>
    <a href="" target="_blank" title="Forums">Forums</a>
    </div>

    <div class='capsule'>
    <a href="" title="Home" target="_self">Home</a>
    </div>Help would be appreciated! 

 

Help would be appreciated!

Do you have a member system implemented in your site? If so, what kind of $_SESSION data (and with what array keys) are set when a user is logged in?

 

Member system is, yes.

 

I am fairly new to php, so where do I find what you need to know?

wp_register() should only show to non-members. If not, modify the source code.

 

There isn't a way to check is someone is an admin, you can check if that person has permission to do something though.

 

Really? How does SMF only show the Admin button to Admins?

 

Also, how would I add "wp_register()" to my source?

 

Thanks for the help!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.