Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Hiding Groups, Activity & Members List to Non Members

  • @wickedbl0ke

    Participant

    I love buddypress. I love it so much that i want to take it behind my school and make it pregnant. But i have an issue now.

    I want to find a way which I can hide the groups, activity and members list page from all non members by redirecting them to another page.

    I used to use member-access for all my other sites but this time, I cant seem to get that plugin to work with buddypress. It just does not work at all.

    Can someone help me in laymans terms find a solution to this?

    PS: I have other pages on this site that I do not want to hide from non members. I have also tried that restrict pages plugin and that does not work either.

Viewing 10 replies - 1 through 10 (of 10 total)
  • @wickedbl0ke

    Participant

    OK. So i found a partial solution.

    I tried adding the below pasted snippet to my bp-custom.php file inside my plugin folder and it worked for the activity page. I dont want to sound like a complete noob but can someone tell me how do i replicate this for the members and group page?

    I tried variations of the code to support _groups_component and _members_component but that didnt work.

    /* Prevent logged out users from accessing bp activity page */
    function nonreg_visitor_redirect() {
    global $bp;
    if ( bp_is_activity_component() ) {
    if(!is_user_logged_in()) { //just a visitor and not logged in
    wp_redirect( get_option(‘siteurl’) . ‘/wp-login.php’ );
    }
    }
    }
    add_filter(‘get_header’,’nonreg_visitor_redirect’,1);

    @shanebp

    Moderator

    So you tried: bp_is_groups_component() and bp_is_members_component() ?

    Use pastebin to post the code you tried.

    @bphelp

    Participant

    @wickedbl0ke
    Untested!

    
    /* Prevent logged out users from accessing bp activity page */
    function nonreg_visitor_redirect() {
    global $bp;
    if ( bp_is_activity_component() || bp_is_groups_component() || bp_is_group_forum() || bp_is_page( BP_MEMBERS_SLUG ) ) {
    if(!is_user_logged_in()) { //just a visitor and not logged in
    wp_redirect( get_option('siteurl') . '/wp-login.php' );
    }
    }
    }
    add_filter('get_header','nonreg_visitor_redirect',1);
    

    @wickedbl0ke

    Participant

    bp-help

    Works like a charm. can i make love to you?

    Thanks

    Resolved.

    @bphelp

    Participant

    @wickedbl0ke
    Negative on the love making but you could donate a beer or two! Or a McDouble even!

    @jannmirch

    Participant

    This has been very helpful and I was able to use it to restrict access to member info but the forum stuff is still visible.

    I have a site that has some non-BP pages – just generic stuff – that I’d like to leave public but want to redirect non members to the registration page when they try to access the forums.

    Any help would be appreciated.

    @jannmirch

    Participant

    Just to clarify…

    I would like all the “regular” pages visible to the public.

    All my BP stuff that resides in mysite.com/forums would redirect for anyone not logged in.

    I hope this makes sense.

    @bphelp

    Participant

    @jannmirch
    Untested, also if you are using sitewide forums remove the comments from:
    /*|| bbp_is_single_forum() || bbp_is_single_topic()*/
    If you are just using group forums leave the below code as is:

    
    /* Prevent logged out users from accessing bp activity page */
    function nonreg_visitor_redirect() {
    global $bp;
    if ( bp_is_activity_component() || bp_is_groups_component() || bp_is_group_forum() || bp_is_page( BP_MEMBERS_SLUG ) || bp_is_profile_component() || bp_is_forums_component()/*|| bbp_is_single_forum() || bbp_is_single_topic()*/{
    if(!is_user_logged_in()) { //just a visitor and not logged in
    wp_redirect( get_option('siteurl') . '/register' );
    }
    }
    }
    add_filter('get_header','nonreg_visitor_redirect',1);
    

    @jannmirch

    Participant

    Thanks so much for your help! This is closer.

    How do I keep non members from seeing the list of forums?

    (And for my own education…how can I find a list of “components” to include/exclude”? I looked in the bp-core-templates.php file but couldn’t get the code to work.)

    @brightestspark

    Participant

    Hi I’m wanting to just hide member profile pages, but keep all other BuddyPress pages public. I tried this code in my bp-custom.php, but it doesn’t work. Any ideas?

    /* Prevent logged out users from accessing bp profile pages */
    function nonreg_visitor_redirect() {
    global $bp;
    if ( bp_is_profile_component() {
    if(!is_user_logged_in()) { //just a visitor and not logged in
    wp_redirect( get_option('siteurl') . '/register' );
    }
    }
    }
    add_filter('get_header','nonreg_visitor_redirect',1);
Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[Resolved] Hiding Groups, Activity & Members List to Non Members’ is closed to new replies.
Skip to toolbar