Skip to:
Content
Pages
Categories
Search
Top
Bottom

Make access members/groups sections members-only


  • peterverkooijen
    Participant

    @peterverkooijen

    What is currently the best way to restrict access to the members and groups sections to members-only?

    There is some code in this thread that works, but it’s a bit of a messy hack – not sure which piece of code in that thread is the final working version – and the solution does not include a working redirect or Ajax message.

    Would it be possible to extend this plugin to work for the members and groups sections in BP?

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

  • Windhamdavid
    Participant

    @windhamdavid

    Burt’s answer on the other thread is Not a hack since it doesn’t touch the core files and works perfectly as a plugin-in or in the /mu-plugins/bp-custom.php file.


    peterverkooijen
    Participant

    @peterverkooijen

    Which is the final code? Does it include error message+redirect so the user understands what is going on?


    Jeff Sayre
    Participant

    @jeffsayre

    Peterverkooijen-

    It seems like your not getting any traction with this issue. I understand your need to have a plugin that restricts group access to only those members within a group.

    As I mentioned in the thread you referenced above, we are working on an overall privacy component for BuddyPress. What you are seeking will be one of the features of this component.

    Perhaps someone will point out an existing plugin that I’m not aware of, or go and create it for you! But, if that does not happen, you at least know that this functionality is in the works.


    peterverkooijen
    Participant

    @peterverkooijen

    There are bits of code all over the place + several plugins for “privacy” or “member access”. I’m just trying to get people’s insights in what currently the best solution is.

    I had tried a version of the code from the previous thread, but it had some problems in the redirect.

    I will try to put something together again as soon as I have time, probably two weeks from now, and will post the result on this thread.

    Sometimes I start threads as reminders to myself, issues on my to do list. Hopefully these threads will turn into useful documentation and summaries of solutions.


    Windhamdavid
    Participant

    @windhamdavid

    this is an easy fix to keep non members out.

    in you’re header for your member theme..

    <?php if(!is_user_logged_in()){

    nocache_headers();

    header(“HTTP/1.1 302 Moved Temporarily”);

    header(‘Location: ‘ . get_settings(‘siteurl’) . ‘/wp-signup.php?redirect_to=’ . urlencode($_SERVER[‘REQUEST_URI’]));

    header(“Status: 302 Moved Temporarily”);

    exit();

    } ?>

    make sure to put it above the <!DOCTYPE….


    peterverkooijen
    Participant

    @peterverkooijen

    Thanks!

    But as with the code in the other thread, I still need to figure out how to let the user no what is going on. I’ll get to it later in June…


    Jeff Sayre
    Participant

    @jeffsayre

    @Peterverkooijen-

    Perhaps we’ll have some component-based solution in an alpha form by then that you can test out.

    The important bit of logic there is the line if(!is_user_logged_in()… basically saying… if the user is not logged in… do this (i.e. direct to homepage). Could you not simply redirect somewhere else? Better yet… could you not simply hardcode your navigation and wrap some of your navigation with this if statement so they don’t even see the links to groups, etc.. Just thinking out loud here.


    peterverkooijen
    Participant

    @peterverkooijen

    @David Lewis, I know. I use something similar a lot in my current site, based on PunBB. I’m not really a coder though, so ‘simply redirect’ will probably require trial and error.

    Hardcoding in the navigation is a good suggestion. I could do that in template files, right?

    Yah… whichever file has your Home, Blog, Groups, Members etc. navigation. You could maybe just hardcode those links instead of using a buddypress function and then wrap the ones your want hidden with that if statement. Again… I’m just talking off the top of my head. I haven’t actually tried this. I think you might have to do it in a few places though since home uses it’s own theme right? Let us know if you get it working. I’m going to want to do a similar trick (for the time being… until the permissions access component is released).

    I just did a quick test. In the home theme at least (wp-content/themes/bphome/header.php) the global nav at the top is already hardcoded. So it’s dead easy to hide the groups and members links simply by wrapping it with this:

    <?php if(is_user_logged_in()): ?>

    [ links for logged in users only go here ]

    <?php endif; ?>

    In my template, the “groups” and “members” links appear on lines 48-53.

    Note that the last item in the navigation is:

    <?php do_action( 'bp_nav_items' ); ?>This function could pulling in more navigation links if you are using any plugins… like bp-events for instance.

    That said… I like the solution in this thread much better.

    https://buddypress.org/forums/topic.php?id=1651&page=2

    The “solution” above is very “low tech” and in fact, isn’t really a solution since it doesn’t actually restrict access… it just hides some links. Probably not a good way to go. You could probably still get into a group by… let’s say… clicking on someone’s profile link and then clicking on a link to a group they are a member of.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Make access members/groups sections members-only’ is closed to new replies.
Skip to toolbar