Hide a Page from Logged out users

I'm using this code to make my buddypress site private to logged in users only, but keeping the blog and non-BP pages available to visitors.

'function sh_walled_garden()
if( ! bp_is_blog_page() && ! is_user_logged_in() )
bp_core_redirect( $bp->root_domain );
add_action( 'wp_loaded', 'sh_walled_garden' );'

I'm now trying to block access to one specific page. I thought I could do it with the same code like this

' if( ! is_page( 697 ) && ! is_user_logged_in() )
bp_core_redirect( $bp->root_domain );'

but I think I've got a few too many exclamation marks creating redirects that will never complete.

Any thoughts on how I can block a specific page from view?

  • aecnu
    • WP Unicorn

    Greetings mrjarbenne Happy New Year!

    Thank you for that great observation and indeed you are correct that you can ask anything you want from my understanding.

    True I am not a coder and actually there is not a single "coder" on the support staff that I am aware of.

    My direct in line Boss and the WPMU DEV lead developer have both defined what is indeed within the scope of the support we do provide here though we do try to help in the event we know the answer.

    I am indeed on your side regarding this subject within the boundaries mentioned above.

    I am for forum rules to include no custom coding what-so-ever and that members certify that they have already performed standard troubleshooting protocol before they can submit a ticket - I must do this before I can submit a ticket with any of my upstream providers of DSL and connectivity for my hosting company, so why not here also?

    However, I admit that neither will probably happen.

    With that said I will go ahead and send an email out to the developer team to see what kind of response we can get form them regarding this coding.

    Though this may take a bit longer then a normal ticket, I will try to get one of them in here asap.

    Cheers, Joe

  • mrjarbenne
    • Site Builder, Child of Zeus

    But Joe is helpful and with his activity on the site, doesn't seem to require much sleep. Very droid-ish. :wink:

    Thanks for the help Cole, I'll give that a shot. On the "what goes where" side of things, did I just not post this in the correct forum? What's the "Advanced Wordpress" forum for? Would that be a more appropriate vehicle?

    Thanks to you both. Have a day.

  • Mason
    • DEV MAN’s Sidekick

    Hiya @mrjarbenne,

    No worries. You're in the right place. We have plans to make the distinction between the two areas more obvious this year. And yes, we'll still be happy to contribute to questions such as this one :slight_smile:


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.