WordPress.org

Ready to get started?Download WordPress

Forums

Child pages of password protected page (4 posts)

  1. shelly.gaudry@gmail.com
    Member
    Posted 11 months ago #

    I have would like to have a password protected "section" that is accessible through 1 password protected page.

    My question is will the child pages of the parent page that is password protected be secure without setting passwords on each child page? I set them all to be password protected with the same password for now just to be sure, but I was a little worried users would have to enter the password for every child page.

    It is a "members" area of our church website where we want to keep our church directory along with schedules like Nursery, mowing, and cleaning. (we are a small church and take turns with the chores)
    Thank you in advance!

  2. Ruth Maude
    Member
    Posted 11 months ago #

    Hi Shelly,

    I suggest trying the Members plugin http://wordpress.org/plugins/members/

    It will allow you to choose which content is for members only. Each member can login with there own account.

  3. AugustWinfield
    Member
    Posted 7 months ago #

    You can use this snippet in your templates to see if pages have a protected parent:

    /* In your theme's functions.php */
    function has_protected_parents ( $post ) {
    	foreach ( get_post_ancestors($post) as $parent ) {
    		if ( post_password_required( $parent ) ) {
    			return true;
    		}
    	}
    	return false;
    }
    
    /* Used in the template (i.e. page.php), inside the loop! (After the_post() has been called) */
    if ( has_protected_parents( $post ) ) {
    	// Tell them to go back!
    } else {
    	// They've already logged in to a parent, or the page doesn't have protected ancestor pages.
    }

    I only know this to work (tested) in the latest release of WordPress, 3.7.1

  4. BangBoomCrash
    Member
    Posted 1 month ago #

    Thanks AugustWinfield - that worked perfectly for a project I'm working on. Thanks again!

Reply

You must log in to post.

About this Topic