Restrict users from seeing each other's profiles?

This topic contains 11 replies, has 3 voices, and was last updated by  Paolo 6 years, 11 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #1210

    Steven Jones
    Free User
    Post count: 5

    Hello,

    Using the shortcode [uwp_profile] the user can see their profile when logged-in on this page URL for example:

    http://mysite.com/my-profile/user1

    But if they edit the URL then they can see any other user’s profile:

    http://mysite.com/my-profile/user2

    Is there a way to stop them from viewing other user’s profiles?

    Best,

    Steven

    #1211

    Guust
    Moderator
    Post count: 29970

    For each field, you can select it to be private or not: UsersWP > Form Builder > Is Public?

    Thanks

    #1213

    Steven Jones
    Free User
    Post count: 5

    Hi,

    Unfortunately that doesn’t change the visibility for the profile.

    #1214

    Guust
    Moderator
    Post count: 29970

    You mean you do not want to allow other users to access the page completely?
    That is not possible for the moment, but you can choose not to have any links to the profile pages, so the only way would be for people to guess other users username.

    Thanks

    #1215

    Steven Jones
    Free User
    Post count: 5

    It’s Ok if other users load the page (they’ll be able to guess the URL as it’ll be the names of their classmates), but the profile avatar and cover image should only load on that page for the user who is logged-in and not be related to the URL.

    #1216

    Guust
    Moderator
    Post count: 29970

    Sorry, but that is not possible without a customization.

    #1217

    Steven Jones
    Free User
    Post count: 5
    This reply has been marked as private.
    #1218

    Guust
    Moderator
    Post count: 29970

    We don’t do customizations, you can try finding an expert at http://geodirectoryexperts.com/

    But one of the developers wrote this snippet you can use in the Code Snippets plugin, see https://wpgeodirectory.com/docs/useful-plugins/#snippets

    
    
    function _uwp_custom_profile_access( $access, $user ) {
        if ( ! ( current_user_can('manage_options') || ( !empty( $user ) && get_current_user_id() == $user->ID ) ) ) {
            $access = false;
        }
    
        return $access;
    }
    add_filter( 'uwp_profile_access', '_uwp_custom_profile_access', 10, 2 );
    
    function _uwp_custom_profile_access_denied( $user ) {
        ?>
        <div><p><?php echo __( 'You are not allowed to view this profile!' ); ?></p></div>
        <?php
    }
    add_action( 'uwp_profile_access_denied', '_uwp_custom_profile_access_denied', 10, 1 );

    Adjust as required. Thanks

    #1219

    Steven Jones
    Free User
    Post count: 5

    Wow thank you – that’s absolutely perfect!

    best,

    Steven

    #1220

    Paolo
    Site Admin
    Post count: 31206
    This reply has been marked as private.
    #1221

    Steven Jones
    Free User
    Post count: 5
    This reply has been marked as private.
    #1222

    Paolo
    Site Admin
    Post count: 31206
    This reply has been marked as private.
Viewing 12 posts - 1 through 12 (of 12 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket