Skip to:
Content
Pages
Categories
Search
Top
Bottom

Restrict member profile views to logged in users


  • seaspray
    Participant

    @seaspray

    I’m new to BuddyPress but enjoying what it can do.

    I’m creating a website/community site for a sailing club and I want to be able to restrict member profile views to cogged in members. Actually, I’d like to make the member directory private too. I can’t quite work out how to do this. In the UK (and Europe) we have strict Data Protection laws and I’m a bit surprised the default seems to be only to restrict Profile edits… Anyhow, if someone can steer me in the right direction I’d appreciate it.

    Many thanks.

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

  • seaspray
    Participant

    @seaspray

    Actually, I’ve discovered that I can resrict profile viewing via the field visibility setting. However, that means setting the level for each field. What I’d still like to do is restrict viewing of any member information (even the existence of a member) to logged in members.


    shanebp
    Moderator

    @shanebp

    Put this in the functions.php file in your child theme or in bp-custom.php
    It will redirect visitors to the home page if they are not logged in and they try to open a member profile or the members directory.

    function seaspray_restrict_members() {
    
    	if ( bp_is_user() || bp_is_members_directory() ) {
    
    		if ( ! is_user_logged_in() ) {
    
    			wp_safe_redirect( home_url() );
    
    			die();
    		}
    	}
    }
    add_action( 'bp_ready', 'seaspray_restrict_members' );

    seaspray
    Participant

    @seaspray

    Very cool – thank you very much 🙂

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