WP SITES

3095 Coded Tutorials & 297 Plugins

Show Password Protected Content To Logged In Users

Add this PHP code to the end of your child themes functions file to display all password protected content to logged in users :

add_filter( 'post_password_required', 'logged_in_show_password_protected', 10, 2 );
function logged_in_show_password_protected( $returned, $post ) {
  
    if ( $returned && is_user_logged_in() )
        $returned = false;

    return $returned;
}

The code enables logged in users to view all password protected content without the need to logon with the password for the protected post/page.

Was this helpful?

Yes
No
Thanks for your feedback!

Leave a Reply