WordPress.org

Ready to get started?Download WordPress

Forums

Show only if logged into password protected page? (2 posts)

  1. Kahil
    Member
    Posted 2 years ago #

    Ok... So I am using the following code to show something only if the page is password protected...

    <?php
        if ( !post_password_required() ) {
                echo 'protected stuff';
        }
    ?>

    The problem is that if I use that code in a place in my template it shows up on all pages using that same template when I'm logged into one of the password protected pages...even if the page I'm viewing isn't password protected. make sense?

    Is there a way to also check if the page you are on is password protected? That way the specific protected stuff is only shown on that page? I don't remember this being an issue in the past, so I'm not sure if it is a new bug or something where the cookie stored isn't page specific.

    I can't figure out why it isn't working so that things only show on the specific password protected page rather than all of them using that template when logged into one of them.

    Thanks in advance.

  2. ktsixit
    Member
    Posted 1 year ago #

    Hi Kahil, I have the same question. Did you find a solution to this one?

Topic Closed

This topic has been closed to new replies.

About this Topic