Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Securing components from non logged in users


peterverkooijen
Participant

@peterverkooijen

OK! I now have this in bp-custom.php:

‘<?

function js_restrict_access(){

global $bp, $bp_unfiltered_uri;

if (!is_user_logged_in() &&

(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?s=1” );

}

}

add_action( ‘wp’, ‘js_restrict_access’, 3 );

?>’

And this in register.php:

‘<?php

if($_REQUEST[“s”]){?>

<script type=”text/javascript”>

jQuery(document).ready(function () {

setTimeout(function(){ jQuery(“#error”).fadeOut(“slow”); }, 6000);

});

</script>

<div id=”error” class=”error”>

<h3>The page you were trying to access is for members only. Please login or register to continue.</h3>

</div>

<?php } ?>’

Does exactly what I want. Thanks Burtadsit! :-)

It would be even nicer if the Ajax would first show the message and then replace it with the registration form: ‘<?php bp_core_signup_do_signup() ?>’

I’ll try to figure that out next weekend…

Skip to toolbar