BuddyDev

Search

[Resolved] Hide member type page from non PMPro members

  • Participant
    Level: Enlightened
    Posts: 23
    Daria Wilczynska on #23533

    Hi Brajesh.

    I have been using your Member Types plugin and I love it however, I just found one issue that I didn’t realize I have.

    I have created couple of few member types and I am linking to them from a menu ( as a Members submenu item) however I realize these sub pages are accessible to people who are not members of my site and I would like to have PMPro restriction on it like you can do with regular BP or non BP pages. For example, this is my main member page which is restricted:

    https://greenteacoffeedate.com/members/

    But I also want this type of page to be restricted:

    https://greenteacoffeedate.com/members/type/samplemembertype

    Is there a checkbox you could add in settings to allow only for PMPro members to see the member type page?

    Thank you and I appreciate your response.

  • Keymaster
    (BuddyDev Team)
    Posts: 21839
    Brajesh Singh on #23539

    Hi Daria,

    Thank you for the topic.

    The restrictions are enforced by PMpro BuddyPress addon and I believe they have forgotten to add support for the member type directory.

    If you want, I can assist with custom code to restrict the member type directory or you can ask the PMPro team to add support for the member type directory restrictions.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 23
    Daria Wilczynska on #23582

    Thanks Brajesh, I asked them about it and will let you know if I need your help.

  • Keymaster
    (BuddyDev Team)
    Posts: 21839
    Brajesh Singh on #23586

    Thank you. I am looking forward to it.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 23
    Daria Wilczynska on #23648

    Hi Brajesh. I spoke to someone at PMPro and she pointed me to this latest github – that it should work however when I uploaded the files to my FTP, I don’t see any difference. The member type pages are still visible to anyone who is not logged in and clicks on the menu subnav. I told her it’s not working for me but had not had a response in couple of days.

    Do you mind taking a look at the code they sent? I kind of want to resolve it sooner than later since I had no idea my members were visible to outsiders. You can’t see the details but you can see a photo, location, how many friends etc.

    https://github.com/strangerstudios/pmpro-buddypress

  • Keymaster
    (BuddyDev Team)
    Posts: 21839
    Brajesh Singh on #23650

    Hi Daria,
    Please put this code in your bp-custom.php

    
    
    add_action( 'bp_template_redirect', function () {
    
    	// Do not lock if user is logged in or we are not on members directory.
    	if ( ! bp_is_members_directory() || is_user_logged_in() ) {
    		return;
    	}
    
    	// If PMPro does not exist or the directory is not locked, return.
    	if ( ! function_exists( 'pmpro_bp_is_member_directory_locked' ) || ! pmpro_bp_is_member_directory_locked() ) {
    		return;
    	}
    
    	// usr is not logged and directory is locked, redirect to login.
    	bp_core_redirect( wp_login_url( $_SERVER['REQUEST_URI'] ) );
    } );
    
    

    Is it working. I haven’t tested it though I hope it should work.

    Please let me know if it works or not?

    Thank you
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 23
    Daria Wilczynska on #23754

    Thanks so much for the code, it does work.

    However, I did some testing on my staging site and realized that there is something broken in the latest version of PMPro BP addon and that’s why it wasn’t hiding the member types. I reverted to previous version on my staging and the member types pages were hidden again. I let the team at PMPro know and they are looking into it.

  • Keymaster
    (BuddyDev Team)
    Posts: 21839
    Brajesh Singh on #23771

    You are welcome.

    I am glad the PMPro old version worked for you.

    Regards
    Brajesh

The topic ‘ [Resolved] Hide member type page from non PMPro members’ is closed to new replies.

This topic is: resolved