0

I'm doing WP page for some small school. I wish to give some special area available just for the teachers. I created one password-protected page which works just fine. I would like to create more and use that first one just to present links to them. I set that main one as parent site to the others. It's important for me that user should be asked for the password just once.

Issues I faced with it:

  1. If I protect all those pages with password (even the same one) than user is asked for it on every single page.

  2. If I protect only first page than all other are visible on sitemap.xml ("Google XML Sitemaps" plugin)

  3. I can exclude some categories from the sitemap but then everyone can search for that category via search bar (I use "Map Categories to Pages" plugin as well)

  4. I consider to use special user for with no permissions and set those pages as "private" rather than "password protected". I didn't test if that user can open such of pages but I would have to redirect user after log-in to that main page somehow (it have to be easy to use even for those teachers who are not much into Internet stuff)

All the information there are not very secret but I would like to at least make sure it'll not pop-up somehow on some search-engine page.

I set Disallow at robots.txt for that area same as I demoted it on Google Webmaster Tools panel. At the same time I got warning from there that it's visible on my sitemap.xml.

Thank you in advance for your help.

0

The easier way can be have a group of users called teachers and give just the teacher's group the permission to visit the page.

There are many plugins for permission handling and grouping users so you'll just need to search WordPress plugin repository. Just an example: groups plugin

Another possible answer can be : multi page password protection (As I wanted to mention the answer owner, I put the link here!)

  • It's fine here to let them share one account (same as they would use shared password for the page) – pawel7318 Dec 4 '14 at 7:34
  • then, you can make a group for just one user, but I don't suggest such a thing! that way you won't be able to know who has done what or at least you'll be in trouble working on other features later on. – mahdionnet Dec 4 '14 at 7:36
  • Answers should be more than plain links. They should actually be an answer instead of a route where someone will maybe find an answer. Please help preventing link rot, edit your answer and provide the needed information that helps the OP as well as later visitors to solve their problem. Even if one of your links or pointers to plugins will be dead, your answer won't work anymore. – Pieter Goosen Dec 4 '14 at 7:44
  • @PieterGoosen - I decided to up-vote that answer too. I think you're right it's better to provide as much detailed answer as possible but sometimes just a plugin name is enough. You can't prevent almost any solution to become outdated in the future anyway. Even if you provide some code it can be deprecated after time (mysql/mysqli PHP functions for example). – pawel7318 Dec 4 '14 at 8:57
  • Well, isn't this the answer for your question? Won't you accept it as answer? – mahdionnet Dec 4 '14 at 9:24
1

I think the better solution would be to create a custom page template for showing content to logged in users only and use that template to all password protected pages.

Then you can create a single user for teachers/staff members so they can log in and view content. This way they will only have to login once on website to view several pages. Even they don't need to login again on each visit.

So here is a sample template I created. It will sow content to logged in users and will display a login form to visitors.

<?php
/**
 * Template Name: Password Protected Page
 */
get_header(); ?>
    <div id="content">
        <?php
            if ( is_user_logged_in() ) :

                while ( have_posts() ) : the_post();
                    get_template_part( 'content', 'page' );
                endwhile;

            else:

                $args = array(
                    'echo'           => true,
                    'redirect'       => site_url( $_SERVER['REQUEST_URI'] ),
                    'remember'       => true,
                    'value_remember' => true
                );

                wp_login_form( $args );

            endif;
        ?>
    </div>
<?php get_footer();
  • Sounds great ! Especially that wp_login_form has redirect parameter. I'll implement this and accept the answer as soon as I check it. Thank you. – pawel7318 Dec 4 '14 at 7:25
  • 'redirect' => site_url( $_SERVER['REQUEST_URI'] ), will make sure that after login user will get back to the page he/she is viewing currently. But you can set it to a fixed location too, for example, the list of pages that you have for teachers. – Robert hue Dec 4 '14 at 7:32
  • Your code works great. It's very useful in case someone wants to use different user/password for every user instead of shared password. Advantage to private pages is that those are not accessible (404) before you log-in. Anyway I up-vote your answer but finally I'll accept mahdionnet's one. I'll explain why below it. – pawel7318 Dec 4 '14 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.