Skip to:
Content
Pages
Categories
Search
Top
Bottom

Hide member page of specific roles


  • xmginc
    Participant

    @xmginc

    Hey guys,

    Would anyone know how to hide and disable member pages based on their role type. (e.g. yoursite.com/members/username)

    Goal: if a member is set to a WordPress Administrator role, we would like to make his/her page inaccessible from the public

    Purpose: while we have been able to hide specific roles from displaying in the member directory, their member/page is still visible if you know the URL.

    Similar to how we can make the WordPress Author page inaccessible, we’d like to do the same for BuddyPress’s equivalent Member page.

    Thanks in advance

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

  • Henry Wright
    Moderator

    @henrywright

    Try this:

    add_action( 'template_redirect', function() {
        if ( user_can( bp_displayed_user_id(), 'manage_options' ) ) {
            // This member is an administrator.
            bp_core_redirect( bp_core_get_root_domain() );
        }
    } );

    xmginc
    Participant

    @xmginc

    Thanks very much Henry, greatly appreciated.

    Apologies for the delay – we have since added Buddydev.com’s Member Types Pro and Profile Visibility Manager so that we can update access on the fly with the various types of users we are growing into.

    I’ve save your code for future though and thx again!

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