Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to make buddypress member profiles private for everyone


  • jaykdoe
    Participant

    @jaykdoe

    I would like all member profiles to be completely private. Members should only be able to access their own profile and nobody elses. Admin accounts should have access as well, but all profiles should be completely private to all other members.

    I have done some research and have found a few people looking for similar solutions, but none exactly like this. Additionally, it appears there may have been some plugins in the past that would have helped but I can no longer find them in the wordpress plugin repository.

    Does anyone know of any plugins or custom code I could add to bp-custom.php to accomplish this?

    Thanks in advance!

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

  • Henry Wright
    Moderator

    @henrywright

    Hi @jaykdoe

    You could try this:

    function my_private_profiles() {
    
        // Bail if not a profile page.
        if ( ! bp_is_user_profile() )
            return;
    
        // Allow admin users.
        if ( current_user_can( 'manage_options' ) )
            return;
    
        // Allow the profile owner.
        if ( bp_loggedin_user_id() == bp_displayed_user_id() )
            return;
    
        // If we get to here, redirect to homepage.
        bp_core_redirect( home_url() );
    }
    add_action( 'init', 'my_private_profiles' );

    You can copy and paste it into your theme’s functions.php file. Please note I haven’t tested.


    Lionel
    Participant

    @prabin04

    well I know a trick to restrict member’s profile to non-logged in user ..


    jaykdoe
    Participant

    @jaykdoe

    @henrywright this worked great, thanks! I was trying to use bp-custom.php but turns out it needed to be in the functions.php file like you said.

    thanks again for your help!


    Patrickasd1
    Participant

    @patrickasd1

    @jaykdoe
    Is this still working?
    Crashed my site when I tried it out


    danbp
    Moderator

    @danbp

    @patrickasd1

    It is working.
    Are you sure you copied correctly the snippet to your theme functions.php file ?
    Triple check what you paste. A missing tag or semi colon can lead to blank page due to a php error.


    ekko848
    Participant

    @ekko848

    This code also crashed my site when trying to add to functions.php


    playdiune
    Participant

    @playdiune

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.
Skip to toolbar