This topic has 12 replies, 3 voices, and was last updated 9 years by Andrei.

  • Author
  • #72842
     dunnyuk
    Participant

    on the blog – under code snippets –
    http://seventhqueen.com/blog/code-snippets/restrict-guest-users-from-accessing-buddypress-or-bbpress-pages.html

    i want to make this work on sweetdate – ive added the code to my child theme functions.php in its original form but it didnt work.
    i also tried changing any reference to kleo – to sweetdate but no joy.

    `/**
    * Redirect buddypress and bbpress pages to registration page
    */
    function sweetdate_page_template_redirect()
    {
    //if not logged in and on a bp page except registration or activation
    if( ! is_user_logged_in() &&
    ( ( ! bp_is_blog_page() && ! bp_is_activation_page() && ! bp_is_register_page() ) || is_bbpress() )
    )
    {
    wp_redirect( home_url( ‘/register/’ ) );
    exit();
    }
    }
    add_action( ‘template_redirect’, ‘sweetdate_page_template_redirect’ );
    `
    any chance of having a look why its not working please.

    #73176
     Laura
    Moderator

    Hello, do not change kleo to sweetdate, should be kleo as sweetdate uses kleo framework
    Using it like kleo it doesnt give any result?

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    Laura Solanes - Graphic Designer and Web Designer

    Please be patient as I try to answer each topic as fast as i can.

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Always happy to help you 🙂

    #73326
     dunnyuk
    Participant

    no it didnt im afraid.

    #73444
     Laura
    Moderator

    Hello, please share admin credentials so i can check it out 🙂

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    Laura Solanes - Graphic Designer and Web Designer

    Please be patient as I try to answer each topic as fast as i can.

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Always happy to help you 🙂

    #73540
     dunnyuk
    Participant
    This reply has been set as private.
    #74297
     dunnyuk
    Participant

    any news on this plse…

    #74958
     Andrei
    Moderator

    I have given a look at the code, updated it a little bit and here is it:

    COPY CODE
    
    
    function redirect_non_logged_in_users(){
        if(
            ! is_user_logged_in() &&
            (
                ( is_buddypress() && ( ! bp_is_blog_page() && ! bp_is_activation_page() && ! bp_is_register_page() ) ) ||
                is_bbpress()
            )
        )
        {
            wp_redirect( home_url( 'register' ) );
            exit();
    
        }
    }
    add_action( 'template_redirect', 'redirect_non_logged_in_users' );
    

    Cheers

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #75625
     dunnyuk
    Participant

    hi Andrei thanks for helping.
    this makes the forums not visible to non registered members but not the group pages or the members pages / profiles which is what i was after.
    any chance of helping me fix this.?

    #75879
     Andrei
    Moderator

    Try to clear your browser cache, when I tested this code you couldn’t access any part of buddypress or member pages/profiles.

    Cheers

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #75993
     dunnyuk
    Participant

    tried that but no joy.
    can you goto the site and click members in the menu and see if its a cache problem my end.

    http://comedinewithus.biz/

    thanks.

    #76062
     Andrei
    Moderator

    I’ve given a second test to the code, here is the updated version:

    COPY CODE
    
    function redirect_non_logged_in_users(){
        if(
            ! is_user_logged_in() &&
            (
                ( is_buddypress() && ( ! bp_is_activation_page() && ! bp_is_register_page() ) ) ||
                is_bbpress()
            )
        )
        {
            wp_redirect( home_url( 'register' ) );
            exit();
    
        }
    }
    add_action( 'wp', 'redirect_non_logged_in_users' );
    

    Cheers

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #76110
     dunnyuk
    Participant

    thank you sir…
    works perfectly.

    #76234
     Andrei
    Moderator

    I’m glad to hear that !
    Cheers

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
Viewing 13 posts - 1 through 13 (of 13 total)

The forum ‘Sweetdate – WordPress’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?