Privacy of members in Corporate theme

Hi,

In Corporate theme, I noticed that on top (header) "members" link is available and even if I am NOT logged in, I see the profile of the member. Is there a way that only logged in users can see the members profile for privacy without restricting the entirety of the homepage?

  • Richie_KS
    • HummingBird

    hi glittereyes

    interesting subject…i know sometime you need to keep member profile and info etc only viewable by logged in/registered users.

    will take note and add an option to the new version of the bpthemes so admin

    can restrict the members and profiles page:slight_smile:

    meanwhile you can try this method

    open up header.php and edit the member nav slug to this

    *this can be apply to any where you don’t want non member to view

    <?php if (is_user_logged_in() ) { ?>

    <li<?php if ( bp_is_page( BP_MEMBERS_SLUG ) ) : ?> class="selected"<?php endif; ?><?php echo BP_MEMBERS_SLUG ?>" title="<?php _e( ‘Members’, ‘buddypress’ ) ?>"><?php _e( ‘Members’, ‘buddypress’ ) ?>

    <?php } ?>

    notice the added bold is_user_logged this will hide the members fro non logged in user.

    now if you even want to restrict the profile page to be viewed by non logged in user…go to themes/profile/index.php and add this line at top of the page before get_header();

    <?php if (!is_user_logged_in() ) { ?>

    <?php wp_redirect(get_option(‘siteurl’:wink: . ‘/wp-login.php’:wink:; ?>

    <?php } ?>

    you can this too to any page you don’t want non logged user to view..

    cheers

  • Richie_KS
    • HummingBird

    did you mean normal wordpress ‘pages’?

    if yes..you can copy this code to your functions.php.

    function restrict_access_by_page() {

    if( is_page( array( 2,100 ) ) ) { //insert page id or page slug ?>

    <?php if (!is_user_logged_in() ) { ?>

    <?php wp_redirect(get_option('siteurl') . '/wp-login.php'); //link to - you can change this ?>

    <?php } ?>

    <?php }

    }

    //apply this filter to all get_header() hook

    add_filter('get_header', 'restrict_access_by_page', 1);

    cheers