Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to make a private community?


  • nipponmonkey
    Member

    @nipponmonkey

    Hi I’m quite new to WP and BP and would like to know the best way to make a private community.

    Basically, I’d like:

    • non members should only see a login/home page with no registration options.
    • non members can not see any posts, usernames or anything else related to the community.
    • all new members can only be created by admin.
    • all logged in members have full posting rights.

    Is this easily achieved? And what’s the simplest approach?

    Cheers

Viewing 25 replies - 26 through 50 (of 104 total)

  • hachimaki
    Member

    @hachimaki

    no, i mean, in functions.php they use to put that /*introduction*/ for locating the functions.

    I put the second method on functions.php, i supose i put it well….

    I use unplugged theme, it says it uses the child theme files… so i paste in the functions.php of bp-default theme your code. and it doesn’t works. I dunno why.


    hachimaki
    Member

    @hachimaki

    Found a much more better solution:

    Use this plugin: Force user login https://wordpress.org/extend/plugins/force-user-login/

    Use this other plugin: http://wpmututorials.com/how-to/custom-branded-login-screen-for-wpmu/ and all done!


    Boris
    Participant

    @travel-junkie

    it’s only a better solution for you, cause you couldn’t get the other one to work :) but anyways, glad you found something that does work!


    hachimaki
    Member

    @hachimaki

    yes, not better, but more simplified…

    i still prefer yours, it’s more accurate, professionalm but… it doesn’t works for me

    regards


    marioe
    Member

    @marioe

    Travel junkie,

    I’m using a regular WordPress install( not MU) can your posting still work for me?


    Boris
    Participant

    @travel-junkie

    well, i’ve got it running on a single install of wp 3.0 alpha, so there shouldn’t be any problems.


    marioe
    Member

    @marioe

    Travel Junkie,

    I’m using 2.9.2 with the buddypress default theme. I’m having no luck. I paste you code on my functions.php file and nothing! any suggestions?


    marioe
    Member

    @marioe

    Travel junkie,

    is working on the members page, and on my groups page, and it wasen’t working on the activity page.

    I had my activity stream as my homepage I change home page to point to a static page and now it seems to work!

    I guess you posting does not apply it static pages.


    Boris
    Participant

    @travel-junkie

    ah, it makes sense now. my code makes all blog pages public, which obviously includes the frontpage as well. so if you’re showing the activity stream there, it would be public. I guess you want to make your complete site private? then the code below should work for you:

    function sh_walled_garden()
    {
    global $bp;

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

    if( ! is_user_logged_in() )
    bp_core_redirect( $bp->root_domain .'/'. BP_REGISTER_SLUG );
    }
    add_action( 'get_header', 'sh_walled_garden' );


    marioe
    Member

    @marioe

    Great, Thanks!


    hachimaki
    Member

    @hachimaki

    lol, so it should work now for me xD


    WPChina
    Participant

    @wordpresschina

    @Travel-Junkie: I used your code above ( https://buddypress.org/forums/topic/how-to-make-a-private-community/page/2#post-44729 ) and it caused my browser to announce that:

    Error 310 (net::ERR_TOO_MANY_REDIRECTS): There were too many redirects.

    Any idea why? Should I change anything within that code to personalize it for my own site?

    Thanks for your posts ^ ^

    I’m finally getting round to setting up a private buddy press site.

    I liked the looks of @Travel-Junkie‘s solution, but I’m having the same problem as @wordpresschina, I’m getting a infinite redirect loop. It seems that functions like bp_is_register_page() and bp_is_home() aren’t working correctly from @Travel-Junkie‘s function.

    I changed it a little to:

    function sh_walled_garden()
    {
    global $bp;

    $uri = $_SERVER;

    $allowed_uris[] = ”;
    $allowed_uris[] = ‘/’;

    for ($i=0; $i < count($allowed_uris); $i++) {
    if ($allowed_uris[$i] === $uri) {
    return;
    }
    }

    if( ! is_user_logged_in() ) {
    bp_core_redirect( $bp->root_domain);
    }
    }
    add_action( ‘get_header’, ‘sh_walled_garden’ );

    Where the $allowed_uris array is set by the programmer to allow access to certain public pages. If the user isn’t logged in and they are trying to access a private page, then they will be redirected to the home page (as that page will be public in my site setup and I don’t want people to be able to register through a sign up page.)

    I’ll have to see how I get on with this solution for now…

    Thanks for your help

    Grrrr, how do you add code to posts in BP?

    I’ve tried pre and code tags, but nothing working >_<

    Hmmmm….


    mistercyril
    Participant

    @mistercyril

    @Travel-Junkie: Hey, your solution works great on my setup (WP MU 2.9.2 & BP 1.2.3).

    I was wondering if you could help me take this one step further…

    I would like my buddypress pages to be accessible only to logged-in users as they are now… but in order to get people to want to log in I think a “teaser” would be a plus. So my question is : How can we make the main BP directory pages accessible to everyone and restrict single groups, profiles, forums… ?

    Thanks again for the great help so far!


    r-a-y
    Keymaster

    @r-a-y

    @mistercyril – Add bp_is_directory() to the bp_is_register_page() line.


    mistercyril
    Participant

    @mistercyril

    Good stuff! Thanks a lot, that works perfectly :-)


    WPChina
    Participant

    @wordpresschina

    @nipponmonkey: I tried your solution above, but now all my pages are blank and nothing is visible… I added it directly to my functions.php and changed/added absolutely nothing. Did I make an error?


    nipponmonkey
    Member

    @nipponmonkey

    @wordpresschina, it’s still working fine for me. I’m using a single WP not WPMU, dunno if that makes a deference or not.

    You should check your server Error Log to see what is going wrong for you. If I get time a might make a plugin that handles everything… but I’m a bit busy at the moment – and there is a World Cup on ^ ^

    Travel Junkie – The first code was great on WP 3.0. Thank you!


    Jamie Marsland
    Participant

    @jamesmarsland

    @Travel-Junkie: Your code below works great for WordPress 3 and Buddypress but not for multisite sub blogs? I need to stop access to sub blogs as well if users are not logged in. If i type in the url of my sub blogs then they show up. Is there anyway to stop this?

    tks
    james

    function sh_walled_garden()
    {
    global $bp;

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

    if( ! is_user_logged_in() )
    bp_core_redirect( $bp->root_domain .’/’. BP_REGISTER_SLUG );
    }
    add_action( ‘get_header’, ‘sh_walled_garden’ );


    r-a-y
    Keymaster

    @r-a-y

    Code in functions.php only runs on the blog in question.

    If you have BP activated sitewide, put the code in /wp-content/bp-custom.php as that will run throughout your install.


    Pisanojm
    Participant

    @pisanojm

    @r-a-y I used your code suggestion and some that I found in Restrict User 2 With Viper’s original Restrict User Plugin
    Found here http://www.viper007bond.com/wordpress-plugins/registered-users-only/
    because I wanted the site to be restricted to registered users only… still allow access to the login/activiate page and ALSO allow access to the feeds…

    I ended up with this.
    // Depending on conditions, run an authentication check
    function MaybeRedirect() {
    // If the user is logged in, then abort
    if ( current_user_can(‘read’) ) return;

    $settings = get_option( ‘registered-users-only’ );

    // Feeds
    if ( 1 == $settings && is_feed() ) return;

    // This is a base array of pages that will be EXCLUDED from being blocked

    if ($bp&&($bp->current_component == BP_REGISTER_SLUG ))//buddypress
    return;

    if ( bp_is_register_page() || bp_is_activation_page() || is_page(‘welcome’) ) //buddypress
    return;

    $this->exclusions = array(
    ‘wp-login.php’,
    ‘wp-signup.php’,
    ‘wp-register.php’,
    ‘wp-activate.php’,
    ‘wp-cron.php’, // Just incase
    ‘wp-trackback.php’,
    ‘wp-app.php’,
    ‘xmlrpc.php’,
    );

    It appears to be working… Do you have any thoughts on the above? Thanks


    Pisanojm
    Participant

    @pisanojm

    Seems like I could have added some kind of IF ~whatever the FEED function~ RETURN to the Registered Users Only 2 plugin and achieved the same thing… but I don’t know what the “whatever the FEED function” is to add… @r-a-y


    r-a-y
    Keymaster

    @r-a-y

    is_feed() is what you’re looking for. However, I would use travel-junkie’s code as it’s cleaner:
    https://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/how-to-make-a-private-community/?topic_page=2&num=15#post-44616

    Modify this line:
    if( bp_is_register_page() || bp_is_activation_page() )

    with:
    if( bp_is_register_page() || bp_is_activation_page() || is_feed() )

Viewing 25 replies - 26 through 50 (of 104 total)
  • The topic ‘How to make a private community?’ is closed to new replies.
Skip to toolbar