Skip to content

Instantly share code, notes, and snippets.

@remkus
Last active February 3, 2020 12:04
Show Gist options
  • Save remkus/7216882 to your computer and use it in GitHub Desktop.
Save remkus/7216882 to your computer and use it in GitHub Desktop.
BuddyPress Privacy
<?php
add_filter( 'get_header', 'bp_guest_redirect', 1 );
/**
* Redirect BuddyPress guests to register page
* @return [type] [description]
*/
function bp_guest_redirect() {
global $bp;
if ( bp_is_activity_component() || bp_is_user_profile() || bp_is_groups_component() || bp_is_blogs_component() || bp_is_page( BP_MEMBERS_SLUG ) ) {
// enter the slug or component conditional here
if ( !is_user_logged_in() ) { // not logged in user
wp_redirect( get_option( 'siteurl' ) . '/registreren' );
} // user will be redirect to any link to want
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment