Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Code snippet: make site private – Parse error


  • admin25
    Participant

    @admin25

    Hello, Iam tring to make my bp site privet with the following code snippet:

    function sh_walled_garden()
    {
    global $bp;
    
    if ( bp_is_register_page() || bp_is_activation_page() )
    return;
    
    if( ! bp_is_blog_page() && ! is_user_logged_in() )
    bp_core_redirect( $bp->root_domain .'/'. BP_REGISTER_SLUG );
    }
    add_action( 'walled_garden', 'sh_walled_garden' );

    I get the error:
    Parse error: syntax error, unexpected ‘/’ in /hsphereXXX on line 245

    Any ideas on how to fix this
    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)

  • aces
    Participant

    @aces

    You don’t say what your add action is hooked to ( or what the line number refers to ). Do you have a `’walled_garden’` hook in your template?

    I would suggest trying the following (I use something similiar but allow access to groups and forums):
    `

    function sh_walled_garden()
    {
    global $bp;

    if( bp_is_register_page() || bp_is_activation_page() )
    return;

    if( ! bp_is_blog_page() && ! is_user_logged_in() )
    bp_core_redirect( bp_get_signup_page() );
    }

    add_action( ‘bp_init’, ‘sh_walled_garden’ );
    `
    I also substitute `add_action( ‘wp_loaded’, ‘sh_walled_garden’ );` on a different site….
    `bp_init` and `wp_loaded` are “native” to buddypress/wordpress so you don’t need to create your own template hook….

    This is in a bp-custom-php file – using buddypress v1.5.5 as I haven’t upgraded to 1.5.6 yet….


    admin25
    Participant

    @admin25

    Hello aces,
    I ran across the code and I thought it was a “this will work with any bp install kind of thing” clearly I was wrong.

    Your code worked perfectly.
    Thank you.


    aces
    Participant

    @aces

    Your welcome…..

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] Code snippet: make site private – Parse error’ is closed to new replies.
Skip to toolbar