Skip to:
Content
Pages
Categories
Search
Top
Bottom

Protect areas from non-member access


  • jacipetersilie
    Participant

    @jacipetersilie

    Hello everybody,

    I haven’t found any solution yet for accomplishing the following access scenario:

    BP pages -> members only
    static pages -> everyone
    posts (dynamic) -> everyone
    events (dynamic) -> everyone

    I’ve tested the plugin BP Members Only. It blocks all pages of the site and excludes specific static URLs from the protection. So far so good. However, it can’t exclude the page area for events/xxx and the posts.

    I can’t believe I’m the only one looking for such a solution for Buddypress. Do you have any code or plugin to recommend?

    I really appreciate any help on this. Thank you so much.

    Jacob

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

  • Henry Wright
    Moderator

    @henrywright

    Hi @jacipetersilie

    This is likely to need a custom solution. For example, events aren’t part of BuddyPress. Are you using a plugin for these? Coding them yourself? The solution you use to restrict access will need to know this info.


    djsteveb
    Participant

    @djsteveb

    @jacipetersilie – Have you tried “press permit core” – I use that on one site for some similar things – but have not tried to get it restrict “bp pages” – as “bp pages” are kind of weird; many of them are not really pages but pseudo pages… yoast program can’t really do much with bp pages as they do not have a taxonomy registered, and no way to “edit this page” to add info to it.

    Not sure what you mean by the “events” pages.

    (my thoughts on this are from a limited knowledge bp user, not a bp dev or code guru -so take with a grain of (my) ignorance )


    jacipetersilie
    Participant

    @jacipetersilie

    Hello guys,

    I’ve resolved this issue with the following code:

    /* 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);

    found in https://buddypress.org/support/topic/hiding-groups-activity-members-list-to-non-members/
    by the user @bp-help

    @djsteveb
    Thank you for that hint. I haven’t checked it out now, cause the code I’ve found looks just fine.

    Hope people who have the same prob find this solution, too.

    Have a great day lovely buddypress community!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Protect areas from non-member access’ is closed to new replies.
Skip to toolbar