Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to disable the member (directory) page?


  • r083r7
    Participant

    @r083r7

    Hi,
    I’m trying to disable the members page that displays a directory of all BP members. Specifically I’m trying to disable the page not just hide it. I don’t want anyone to be able to guess the url or some other way access this page to view all members on the site.

    I found this https://buddypress.org/support/topic/disable-member-directory/ but the code didn’t work.

    Any other ideas?

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

  • danbp
    Moderator

    @danbp

    Hi,

    “member” is a core component of BuddyPress and can’t be disabled. You need the “member” slug (or what ever you may use as custom slug) in the wp environment, for example to fire profiles, messages and so on.

    You want to obfuscate or forbid the member directory. That’s ok. Let’s make it simple and stupid! One possibility would be to add a restriction on the directory template. For example, you could allow only the site admin to access that part. Other roles will get a message instead (or nothing at all, or a redirection…).

    If i’m right, the directory template is in bp-legacy/buddypress/members/index.php
    Condition you could use:

     if ( !is_super_admin() ) {
     echo 'This page is not public';
    } else {
    // here the template content
    }

    To use this solution you need to use a child theme.
    There are many other ways to accomplish what you want. Here the most simple(imo), but you can go to overcomplicated and very sophisticated too.


    r083r7
    Participant

    @r083r7

    Thanks!


    jchretien
    Participant

    @jchretien

    It seems this directory stuff was depracated in the location you mentioned. Does this still exist? I need to hide this page too from anyone not admin. We use this in the medical space, so we WANT to show those that are assigned as Therapists, but we CANNOT show the people that sign up as a patient.


    emaralive
    Participant

    @emaralive

    Hi @jchretien, in lieu of trying to hide the Members directory; have you considered using Member Types as a way to filter which Members are listed within the Members directory (as in admin (list all) vs non-admin (only list Therapists)?


    Varun Dubey
    Participant

    @vapvarun

    @jchretien
    Replace ‘your_member_type’ with the actual slug of your desired member type.

    function wbcom_custom_bp_members_filter($args) {
        // Only apply the filter for non-admin users
        if (!current_user_can('manage_options')) {
            // Specify the member type you want to display
            $desired_member_type = 'your_member_type';
    
            // Set the member_type argument to filter the members list
            $args['member_type'] = $desired_member_type;
        }
    
        return $args;
    }
    add_filter('bp_after_has_members_parse_args', 'wbcom_custom_bp_members_filter');
Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Skip to toolbar