Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to restrict non logged in users from viewing profiles?


  • digitman2
    Participant

    @digitman2

    I’m simply looking for a hook or filter, or any other way to stop non logged in members from viewing a profile. This applies to all tabs within a member’s profile (activity, friends, profile, etc)

    Ideally it would be a hook/filter that’s called just before/after the component is loaded, so that I could redirect the user to a login/register page.

    I can’t find anything for this so far. Any ideas?

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

  • intimez
    Participant

    @intimez

    @digitman2

    I believe this plugin will help you with restrictions


    digitman2
    Participant

    @digitman2

    I don’t think so? It seems to be adding a whole different type of profiles. All I want is to be able to redirect non logged in users away.


    danbpfr
    Participant

    @chouf1

    hi digitman2,

    you can do this from within your child theme.
    your_child/members/single/profile/profile-loop.php

    At the begin of the file add this:
    <code> if ( is_user_logged_in()  ) :  (within  php tags)</code>

    and this at the end of the file, just before the latest do_action
    <code><?php else : ?>
    <?php echo “div style=’width: 600px;height:25px; padding: 4px; border: 3px solid #ff0000; text-align: center; font-style:bold; font-size: 1.3em;’> You have to login to view a member’s profile./div”; ?>
    <?php endif; ?></code>

    Take care wwith copy pasting, some html tags are not complete

     

    You couldn’t find this?!

    https://buddypress.org/support/topic/how-to-make-a-private-community/?topic_page=6&num=15/#post-86316

     

    Obviously play around with the code to get what you need  but that’s the basic principle for a re-direct away from pages wanted to be made private.


    intimez
    Participant

    @intimez

    @digitman2

    I’m testing it in a LAN environment with activity and members link so that anyone that is not logged in, they are unable to see those section and it redirects to registration page. Just one suggestion but maybe other suggestions easier.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to restrict non logged in users from viewing profiles?’ is closed to new replies.
Skip to toolbar