Skip to content

Instantly share code, notes, and snippets.

@shaynesanderson-zz
Created May 6, 2013 22:11
Show Gist options
  • Save shaynesanderson-zz/5528654 to your computer and use it in GitHub Desktop.
Save shaynesanderson-zz/5528654 to your computer and use it in GitHub Desktop.
Lock BuddyPress to only logged in users
<?php
// **** Privacy ********
function restrict_access(){
global $bp, $bp_unfiltered_uri;
// If user is not logged in and
if (!is_user_logged_in() &&
(
// The current page is not register or activation
!bp_is_register_page() &&
!bp_is_activation_page()
)
) {
// Redirect to registration page. Change /join to your register page slug
bp_core_redirect( get_option('home') . '/join' );
}
}
add_action( 'wp', 'restrict_access', 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment