WordPress.org

Ready to get started?Download WordPress

Forums

Password Protected Posts only for Logged Out Users (6 posts)

  1. rachelbilski
    Member
    Posted 2 months ago #

    I have a number of posts, most can only be viewed by a logged in user, but some are password protected for both logged in and non-logged in users to view.

    I need to have the password protected posts so that only non-logged in users need to enter the password, for logged in users the post should just be visible, but I can't seem to manage this, they still need to enter the password.

    Any ideas?

  2. Chris Hardie
    Member
    Posted 2 months ago #

    Hi. The way you handle this may depend on how many different users with accounts who log-in you need to handle. This page:

    http://codex.wordpress.org/Content_Visibility

    notes that logged in users can view password-protected posts in the "Edit" screen of the post management interface, so if you only have one or two who need to get around the password requirement, this could be a way to do it.

    If you need to handle lots of users and/or it's important that they view the post in the same way that logged-out users will, you may need to explore using a plugin or even adding custom functionality to WordPress, e.g.

    http://wordpress.org/plugins/search.php?q=password+protect

    I hope this helps.

  3. rachelbilski
    Member
    Posted 2 months ago #

    Hi Chris,

    Thanks for your response! It is important that they can view this in the same way as logged out users unfortunately. I have searched for a plug in but nothing seems to fit my requirements.

    My main problem is I cannot find a way of intercepting the password form/blocking of content, it's all part of the function of get_the_content (from post-template.php) as here:

    if ( post_password_required( $post ) )
    		return get_the_password_form( $post );

    I can't find a relevant pluggable function or hook for altering this behaviour, so without editing core files (obviously a no no!), I can't see a way around it, unless I'm missing a function somewhere.

    Thanks!

  4. Chris Hardie
    Member
    Posted 2 months ago #

    Yeah, I think you may be crossing into the realm of needing custom plugin development. As you note, it could get messy to start modifying WordPress's built-in functionality to do what you want, so I would recommend either building your own plugin or trying to find a plugin developer who could help you build what you want.

  5. Jeremy Pry
    Member
    Posted 2 months ago #

    There's a ticket currently in Trac to add a filter to the post_password_required() function. If this filter is added, it would make it very easy for a Plugin to do what you want to do.

    Ticket link:
    https://core.trac.wordpress.org/ticket/20717

  6. rachelbilski
    Member
    Posted 2 months ago #

    Thank you, Jeremy, I will keep an eye on that, it'd be really useful!

Reply

You must log in to post.

About this Topic