2

GOAL: Develop a password-protected user directory without a membership plugin. The login credentials are the same for everyone.

QUESTION: Will this strategy keep the info private, or am I missing something?

  1. Create a custom post type with options:

    'public' => true,
    'has_archive' => false,
    'exclude_from_search' => true,
    'publicly_queryable'  => false,
    
  2. create a password-protected page with a custom page template, displaying the custom post type query (the list of addresses).

  3. add a password form to the custom page template, like so:

    global $post;
    get_header();
    if ( ! post_password_required( $post ) ) {
        // …
    } else {
        echo get_the_password_form(); 
    }
    

Additional Notes:

  • Custom Post Type paired with Advanced Custom Fields will set up fields for address, phone numbers, names, etc.
  • An editor (or two) will keep the directory up to date
  • "what do you think" is an invitation for a discussion which is not how the site works. Personally I do not even know what does HOA means. The question probably needs rewriting and focusing on asking one question at a time or at lest research and present the alternatives – Mark Kaplun Aug 21 '17 at 17:29
  • edited to make simpler. sorry about that. – Sarah Aug 21 '17 at 17:36
  • 1
    Please save yourself a TON of hassle in the future and DO NOT use a single username/password for everyone to use. This is not secure and it is a huge pain in the admin's rear end if any single person needs to be removed from access. You'd need to set new credentials and send to everyone. Use a membership plugin - that's what they are for. Then, when someone needs to be removed from access, you shut off one person without inconveniencing every other user. – butlerblog Aug 21 '17 at 21:38
  • whether everyone has the same password or not (this can easily be sent out in the monthly newsletter), there should be way to do this without a plugin. after all, plugins are just code? and it looks like you write a membership plugin? how do any of us become better developers if we just keep using plugins? – Sarah Aug 22 '17 at 0:07
4

You might want to read this post about passwords protected posts. In short: Do not use them.

QUESTION: Will this strategy keep the info private, or am I missing something?

No, it won't. It will even leak info to search engines and index those.

What you can do is to just require the actual user login in your template:

// @link https://developer.wordpress.org/reference/functions/is_user_logged_in/
if ( ! is_user_logged_in() ) {
    // @link https://developer.wordpress.org/reference/functions/wp_login_form/
    wp_login_form();

    // "outer template"
    wp_footer(); # etc.
    return;
}
// Other template code

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.