WordPress.org

Ready to get started?Download WordPress

Forums

How to password protect page and all subpages easily... (4 posts)

  1. Trevor Gehman
    Member
    Posted 4 years ago #

    Long time WordPress user. I just ran into this issue developing a site for a client, so I figured I'd save someone else the time figuring out how to do this.

    I used this plugin: http://fullthrottledevelopment.com/password-protect-children-pages/

    The limitation is that only the immediate child pages are protected. In my case I had several layers of pages and subpages, and I wanted everything to be password-protected.

    So, based on this (http://codex.wordpress.org/Template_Tags/wp_list_pages#List_whole_subpages) I edited the plugin code:

    // This function prints the password form if the parent page is password protected. It is called whenever 'the_content' is invoked.
    function ft_password_protect_children_page_contents( $org_content ){
    	if ( is_page() ){
    		global $post;
    $ancestors = end($post->ancestors);
    		if ( !empty($ancestors) ){
    			if ( post_password_required( $ancestors ) ) {
    				$real_post = $post;
    				$post = $ancestors;
    
    				echo get_the_password_form();
    				$post = $real_post;
    				return;
    			}
    		}
    	}
    	return $org_content;
    }

    Seems to work perfectly. Now all I do is put a password on a page, and all its subpages are protected with the same password. Makes it easy to password protect an entire section of your blog.

  2. Glenn Ansley
    Member
    Posted 3 years ago #

    Thanks,
    I've applied this update and a couple others to the plugin. I'll be submitting it to the repository shortly.

  3. petrusfajarsubekti
    Member
    Posted 3 years ago #

    Hmmm thank you :)
    I want my blog be limited blog. And i want only some member who know the password open it.

  4. julesvern97
    Member
    Posted 3 years ago #

    I posted on an issue I was having with this particular plugin elsewhere; I've not received a response, though I hope I either figure it out or someone has a suggestion to that problem.

    My question is this: is it possible to set up the password protected pages to have multiple passwords (i.e. a different password for each user to access the pages) instead of one password for multiple users to access the pages?

    I see this question being asked all over these support forums and so it isn't just me wanting a chunk of pages password protected and available to "subscribers" with their own unique password. Any thoughts?

Topic Closed

This topic has been closed to new replies.

About this Topic