Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] hide profile from non-logged-in users

  • @ckchaudhary

    Participant

    Hello people,
    I have a requirement wherein users are required to be logged in to view someone else’s profile. Other section (Blog etc..) are open to guest users though.

    I was worndering if someone else has done this before already and can save me from digging into bp code to get to a solution.

    Any help is greatly apprecited.
    Thnx

Viewing 18 replies - 1 through 18 (of 18 total)
  • @chouf1

    Participant

    Hi,

    you have to modify from within a child theme the profile-loop.php file
    your-child-theme/members/single/profile/profile-loop.php

    On the first line of the file, add <code><?php if ( is_user_logged_in()  ) : ?></code>

    At the end of the file, insert between the last endif and the last do_action this:

    <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 must be logged in to view a member profile</div>”; ?>
    <?php endif; ?></code>

    Change the div inline style to whatever you need accordingly to your theme. The example fits with bp-default.

    @chouf1

    Participant

    Take care by copy/pasting from here, the <code> tags belongs to the forum. Must be retrived.

    @ckchaudhary

    Participant

    @Chouf1 thanks. works like a charm.
    Since i didn’t want anything (even the avatar image) to be displayed to non-logged in users, i added the code in home.php instead (and plugins.php, since i have 2-3 custom pages added to users profile).

    Many thanks.

    @needhelp101

    Participant

    I tried using the codes and got a “parse error” I am using buddy press with the Graphene theme. Please let me know what further adjustments I may need to make.

    @ckchaudhary

    Participant

    I am sure it must be some typo mistake as the code isn’t complicated or error prone. Make sure while copying the code from here, you copy it correctly and have removed unwanted formatting

    @michael4fm

    Participant

    Just thought I’d add another suggestion – there’s a plugin called Member Access (http://www.chrisabernethy.com/wordpress-plugins/member-access/) which controls access to pages based on whether a visitor is logged in or not. I’m using it successfully on a BuddyPress site. I think you’d have to disable access to the “Member Directory” page as well for it to work ‘out of the box’, but with some php tweaking  you may be able to have the directory page show but restrict access to more detailed profile information.

    @sosyalorgu

    Participant

    thanks

    @aldereteka

    Participant

    Hey @Chouf1

    Can your code be modified for private messaging? I’m trying to make the private message button on profiles visible when someone is logged out, but redirected to log in/register when a logged out/unregistered user attempts to contact someone. Can anyone point me in a general direction?

    Thanks.

    @chouf1

    Participant

    @aldereteka,

    No !

    But why do you want to retro pedaling ? Those buttons are not visible for visitors. Reverting this just to redirect them to the login page and hoping they come back after registering is fussy !

    I would suggest you to write a short message like:

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

    <div>If you were logged in you could send a message to this member. </div>

    <?php endif; ?>

    @aldereteka

    Participant

    @chouf1

    Thanks for the response, suggestion, and snippet. I agree that it’s fussy. I’ll reflect.

    @bphelp

    Participant

    @aldereteka
    Try this:
    https://github.com/bphelp/private_community_for_bp
    edit it to meet your requirement.

    @scotm

    Participant

    @bphelp I’ve removed the comments as instructed to hide sitewide forums but they’re still visible to me when logged out.

    /*|| bbp_is_single_forum()*/

    @bphelp

    Participant

    @scotm
    Please provide a little more info on your install. WP/BP/Themes etc.

    @scotm

    Participant

    I’m using 3.5.1, 1.7, SocialBuddy from Swish Themes.

    @bphelp

    Participant

    @scotm
    If you removed the comments /* */ || bbp_is_single_forum() it should work. I am using a new install of WP 3.5.1 and BP 1.7 and I tested it with the default theme , twenty twelve and the Responsive Theme and it still works for me. Maybe its your theme or a plugin you have installed that is failing. Try a different theme because I can’t replicate the issue.

    @scotm

    Participant

    I tried it with the BP Default theme and it still won’t hide forums.

    @bphelp

    Participant

    @scotm
    Strange, it works perfect for me. Maybe its a plugin interfering because on my install I only have BP, BBPress, and Private Community activated. If I log out it redirects me to the registration. If I click the forum nav button it redirects me to registration as well. Do you have other plugins installed besides the ones I listed?

    @dainismichel

    Participant

    hi i made a test user here:

    http://www.curetinnitus.org/members/testeruser1/profile/public/

    but if you’ll notice all other buddypress functionality redirects to a registration page, and that redirect is handled by wishlist member.

    if you go here

    Members

    you’ll get redirected.

    BUT — obviously i only want profiles visible to logged in users. the rest of the site looks to be functioning properly.

    I’m using the twentytwelve theme and have a child theme set up — and am using that.

    Does the above info mean that I would create the directories

    /members/single/profile/

    and create fileprofile-loop.php

    ?

Viewing 18 replies - 1 through 18 (of 18 total)
  • The topic ‘[Resolved] hide profile from non-logged-in users’ is closed to new replies.
Skip to toolbar