Skip to:
Content
Pages
Categories
Search
Top
Bottom

Hide profile page of admin from other users

  • @dreamh11

    Participant

    I have installed buddypress and bbpress both in my website http://dreamhomeguide.in where users can create topics on different forums. Now when admin replies any topic other users can easily check the profile page of admin. Is there any way by which I can hide the profile page of admin from other users?

Viewing 6 replies - 1 through 6 (of 6 total)
  • @henrywright

    Moderator

    Hi @dreamh11,

    Try adding this to your theme’s functions.php file:

    function hide_admin_profile() {
    
        // Bail if this is not a profile.
        if ( ! bp_is_user_profile() )
            return;
    
        // This assumes the member ID of the admin user is 1.
        if ( 1 == bp_displayed_user_id() ) {
            // We're trying to view the admin's profile so redirect to the homepage.
            wp_redirect( home_url() );
            exit;
        }
    }
    add_action( 'init', 'hide_admin_profile' );

    @shanebp

    Moderator

    There are a few issues with that solution.
    1. ‘1’ can’t view their own profile
    2. What if there are multiple admins

    Suggestion:

    function hide_admin_profiles() {
    
        // Bail if this is not a profile.
        if ( ! bp_is_user_profile() )
            return;
    
        if ( ! is_super_admin() ) {
             if ( is_super_admin( bp_displayed_user_id() ) ) {
                 wp_redirect( home_url() );
                 exit;
             }
        }
    }
    add_action( 'init', 'hide_admin_profiles' );
    

    @iburnthings

    Participant

    Can this be modified for subscribers?

    @henrywright

    Moderator

    Nice @shanebp 🙂

    @henrywright

    Moderator

    @iburnthings it sure can but how exactly do you mean?

    @iburnthings

    Participant

    https://buddypress.org/support/topic/hide-profiles-of-a-specific-role-not-admin/

    I created a new thread. Sorry to hijack/resurrect this thread.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Hide profile page of admin from other users’ is closed to new replies.
Skip to toolbar