Re: Securing components from non logged in users
I think there was one } missing in Enlightenmental1’s latest version:
<?
function js_restrict_access(){
global $bp, $bp_unfiltered_uri;
if (!is_user_logged_in() &&
(BP_MEMBERS_SLUG == $bp_unfiltered_uri[0] ||
BP_GROUPS_SLUG == $bp->current_component ||
BP_BLOGS_SLUG == $bp->current_component)){
bp_core_redirect( get_option('home') . "/register" );
}
}
add_action( 'wp', 'js_restrict_access', 3 );
?>
How can I make this work for a custom page/component? How is BP_GROUPS_SLUG etc. defined?
I’ve tried adding this to the top of my custom page, but that did not do the trick:
/* Define the slug for the component */
if ( !defined( 'BP_EVENTS_SLUG' ) )
define ( 'BP_EVENTS_SLUG', 'events' );
This doesn’t work either:
if (!is_user_logged_in() &&
(BP_MEMBERS_SLUG == $bp_unfiltered_uri[0] ||
BP_GROUPS_SLUG == $bp->current_component ||
BP_BLOGS_SLUG == $bp->current_component ||
get_option('home').'/events' == $bp->current_component)){
...