BuddyDev

Making a WordPress & BuddyPress Site Private, the Right Way

Do you plan to make a WordPress & BuddyPress site private? Most of the plugins that claim to make a site private fail with BuddyPress activated. The problem is BuddyPress resets page ids for the pages used by BuddyPress. The simple solution that works with BuddyPress as well as WordPress is to hook into template_redirect action early.

Here is a snippet that prevents the users from viewing BuddyPress site content. We have excluded login page, register page, activation page and home page from the list.

You can put the above code in your theme’s functions.php or bp-custom.php in the plugins directory.

Hope that helps. Feel free to modify it and use it for your specific purpose.

5 Responses to Making a WordPress & BuddyPress Site Private, the Right Way

  • Thank you for this snippet! Finally something that works. Question, though: How would you exclude blog-posts from becoming private? Meaning – keep blog-posts visible to the public?

  • Thank you Maite,
    Glad it worked.

    You can add the following lines before line 32 above

    and that will do it.

    Best Regards
    Brajesh

Subscribe