• mattpryor

    (@mattpryor)


    how can i make it so that my blog-page itself will know whether or not registered users are logged in?

Viewing 3 replies - 1 through 3 (of 3 total)
  • davedorm

    (@davedorm)

    I did a little dirty hack on my page because I have Viewlevel plugin installed and also require users to be registered to comment.
    I moved the login/register code to the top of my page and did a little playng with the code. It basically checks to see what the user level of the logged in user is, then displays info according. If they are above userlevel 0, it displays the name and (thanks to Alex’s Since last Login plugin) number of new posts and comments. If they are below 1 (not registered) it displays the login block and a little blurb about why logging in is so very cool. The

      tags are there so as to not break the right column lists.
      <!-- USER LEVEL / ELIMINATE LOGIN BLOCK -->
      <?php if ($user_level > 0) {?>
      <small><small>Welcome, /wp-login.php"><?php echo ($user_nickname); ?>!

      <script type="text/javascript">slvBanner();</script></small></small>

        <?php } ?>
        <?php if ($user_level < 1) {?>
        <li id="friends"><?php _e('Friends of Dave'); ?>

      <?php } ?>
      <!-- END BLOCK -->
      Hope this helps someone. It works for me.

      you know, this also works as a crude password-protection script, if you put the “loop” inside the <?php if ($user_level > 0) {?> and <? } ?> parts. =) Yes, I know there are plugins that do this, but some people are having header output problems with those heh 😉

    Viewing 3 replies - 1 through 3 (of 3 total)

    The topic ‘main page notices logins’ is closed to new replies.