Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Securing components from non logged in users


peterverkooijen
Participant

@peterverkooijen

One problem:

When you try to enter the members section when you\’re not logged in, you\’re forwarded to the registration page with that fancy fade-out error message. In the address bar you\’ll have something like this:

http://mywebsite.com/register?s=1

Unfortunately when you then log in on that page, you\’ll get the error message again while you\’re getting logged in and you\’ll stay on register?s=1 where you\’ll see this message in the page:

You\’re logged in already. No need to register again!

Did I introduce mistakes in my version of the code?

Is it possible to expand this code with an \”if logged in, forward to homepage in 0 seconds\” bit of php magic?:

‘<?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 } ?>’

If that code gets too long, it is possible to turn it into an nice include or function, perhaps somehow included in bp-custom.php?

Skip to toolbar