Skip to:
Content
Pages
Categories
Search
Top
Bottom

Profile fields visible to admin and the logged in user only

  • @akent64

    Participant

    I’m hoping someone can help me.

    I would like users profiles to be viewable and editable by admins and the logged in user only.

    This means that a logged in user can edit his/hers own profile but no other members are able to view that information.

    Is this possible and how?

    Thanks in advance

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

    Participant

    you can’t really hid the entire profile out of the box but you can hide most of the fields and info by setting the default visibility in the profile field setup screens.

    @mossyoak

    Participant

    My portal theme only lets admin / editor users view all members profiles or other users view other profiles if they are friends. If you want more info on how I did this let me know.

    @scimea

    Participant

    @mossyoak How did you accomplish that?

    I need a solution that allows only the user (and the admin) to see their own profile. I need it so members not involved (@mentioned) in conversations on activity strea cannot see them.

    Only the members involved and the admin should be able to see the conversation.

    Thanks,
    Adam

    @mossyoak

    Participant

    I use a WordPress theme I made to accomplish this. I’ve been asking on the forums if anyone wants me to release it for free but I’ve had no response/ interest from anyone yet. https://buddypress.org/support/topic/flat-portal-client-area-child-theme-of-twenty-thirteen/

    It has all the functionality you want.

    I made it so that only admin can see all the users and only friends can see each others profiles if not admin.

    @mossyoak

    Participant

    I mis-read your question sorry. I found a solution which lets users only view other users profiles if they are a friend of that user. The admin can see all members regardless of them being his/her friend.

    I put the function in my functions.php:

     // BuddyPress create conditional if friend
    function flatportal_bp_is_friend() {
    global $bp;
    
    if (friends_check_friendship( bp_loggedin_user_id(), bp_displayed_user_id() )  )
    return true;
    
    return false;
    }

    and created a custom header file with this at the top:

    // Global $bp variable holds all of our info

    global $bp;
    // The user ID of the currently logged in user
    $current_user_id = (int) trim($bp->loggedin_user->id);
    // The author that we are currently viewing
    $author_id  = (int) trim($bp->displayed_user->id);
    if ($current_user_id !== $author_id && !current_user_can('delete_others_pages') && !flatportal_bp_is_friend() )
    {
    wp_redirect( home_url() );
    exit();
    }

    Then in header php (using multiple headers)

    elseif ( bp_is_user()):
    get_header('restrict-profile');

    If they are not a friend they will be redirected to the home page or wherever you want them. I suppose you could re-direct them to a “you are not a friend of this user” page if you wanted.

    @buddyboss

    Participant

    You can use a plugin like s2Member: http://www.s2member.com/

    Not as clean as hard-coding it, but this can potentially solve your problem. You could use it to redirect users off of profiles you don’t want them to see.

    Otherwise you’ll need to hard code it using a combo of IF statements.

    // Check if user is logged in
    if ( is_user_logged_in() )

    // Check if user is on his/her own profile while logged in
    if ( bp_is_my_profile() )

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Profile fields visible to admin and the logged in user only’ is closed to new replies.
Skip to toolbar