• Hi all,

    i know this is a topic that has already been talked/written about a lot.
    And i searched and read a lot about the subject, but i just cant seem to find the answer i’m looking for.

    I have a few wordpress sites running, and i love WP.
    Now i want to make a WP site for oure employees, sort of intranet.
    The site has to be completely locked for anonymous users. only employees (members) can log in and see all content.

    i tried some plugins, but most only block the content (page/post) but menus still show.

    i dont need all the fancy membership options. I just want the site protected and show only a basic info page and login form when people are not logged in. when the log in, they get to see the whole site.

    does anybody have a good tip on how to do this? which plugin?

    thanks in advance!

    Martin

Viewing 4 replies - 1 through 4 (of 4 total)
  • Martin,

    We wrote a relatively simple free All-In-One Intranet plugin designed just to protect the entire site as you describe:

    http://wordpress.org/plugins/all-in-one-intranet/

    There are a few other plugins out there for ‘privacy’ rather than ‘membership’ if ours doesn’t fit your requirements for some reason.

    I hope this helps!

    Thanks,

    Dan

    Anonymous User 13528887

    (@anonymized-13528887)

    The following code will allow you to force the user to login before viewing your website.

    Paste the following code in your functions.php file

    function my_force_login() {
    if (!is_single() && !is_user_logged_in()) {
    auth_redirect();
    }
    }

    And Drop following code in your themes header file;
    <?php my_force_login(); ?>

    Thread Starter mkrve

    (@mkrve)

    thanks both of you… this helped me out a lot.
    i was thinking way to complex 🙂

    both solutions work fine….

    i got the site protected, but…. can i then combine it with one of the “member” plugins?
    now people can login, thats great, but i dont want to display the top bar after login, and i dont want them to access the /wp-admin/profile.php page etc.

    idealy i use a custom (front end) login and front end pages for editing there profile etc.

    got any tips on a good, not to complex plugin for this?

    thanks so far for the help!

    Martin

    Anonymous User 13528887

    (@anonymized-13528887)

    Hey,

    This will block access to dashboard for non-admin users

    add_action( 'init', 'blockusers_init' );
    function blockusers_init() {
    if ( is_admin() && ! current_user_can( 'administrator' ) &&
    ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
    wp_redirect( home_url() );
    exit;
    }
    }

    and this will hide the admin bar at top from non-admin users

    add_action('after_setup_theme', 'remove_admin_bar');
    
    function remove_admin_bar() {
    if (!current_user_can('administrator') && !is_admin()) {
      show_admin_bar(false);
    }
    }
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘restrict complete WP to members only’ is closed to new replies.