WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] hide sidebar from users that arent logged in (6 posts)

  1. mc_raz
    Member
    Posted 2 years ago #

    I'm using the restrict content plugin which works really well but the sidebar still shows the normal content to users that are not logged in.

    Currently my single.php grabs my "main" sidebar with...

    <?php get_sidebar('main'); ?>

    I was hoping to add a conditional tag that grabs the "default" sidebar if a user is not logged in.

    Thanks in advance to anyone offering help!

  2. Digital Raindrops
    Member
    Posted 2 years ago #

    Try is_user_logged_in()

    <?php if ( is_user_logged_in() ) get_sidebar('main'); ?>

    If this is the solution please mark the post resolved.

    HTH

    David

  3. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    a conditional tag that grabs the "default" sidebar if a user is not logged in.

    extended from David's reply:

    <?php if ( is_user_logged_in() ) { get_sidebar('main'); }
    else { get_sidebar(); } ?>
  4. Digital Raindrops
    Member
    Posted 2 years ago #

    Hi alchymyth,
    I missed that bit!

    David!

  5. mc_raz
    Member
    Posted 2 years ago #

    Thanks guys, I am only reasonably new to this stuff. I am at the point where I am starting to understand what needs to be done but implimenting it still confuses me at times. Your suggestions worked perfectly and I was then able to use it to fix another problem that I discovered too.

    Thanks again for your help!

  6. Thanks for helping out, David! mc_raz, I hope you continue to enjoy the plugin :)

Topic Closed

This topic has been closed to new replies.

About this Topic