Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: How to hide section of profile to all but that user and admin?

@henrywright

Moderator

Hi @screampuff

You could try the following function which will stop unwanted users from viewing the page directly if they tried typing the URL:

function my_hide_achievements_page() {
    $role = xprofile_get_field_data( 'Membership' );

    if ( ( $role != 'Administrator' ) || ( bp_current_user_id() == bp_displayed_user_id() ) )
        return;

    // I guess we should 404 this page because this member isn't an admin or the displayed member.
    $wp_query->set_404();
    status_header( 404 );
    nocache_headers();
}
add_action( 'init', 'my_hide_achievements_page' );
Skip to toolbar