BuddyDev

Search

Create separate member types that can't see each other

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

    Hello, this is a question for Brajesh. I need advice whether any of your plugins might do what I need for my site.

    I have a buddypress dating site which is currently only serving US and Canada but I would like to have it open to international members however I would like to create separate regions which can’t see each other.

    I currently use Paid Memberships Pro and I was planning to have separate memberships for different world regions (about 5 or so ) so those members can only see and search the members from that region. They would be assigned a member type of sort at sign up and maybe have a separate members pages or just one big members page ( and activity page ) but with filtered results based on their member type. Do any of your plugins offer that separation and filtering?

    I see you have Member Types Pro, would that do the trick? Or in combination with another plugin? I hope it makes sense what I’m trying to do.
    Unless you recommend there is a different way to achieve the result with any other plugins that you offer.

    https://buddydev.com/plugins/buddypress-member-types-pro/

    Thank you

    Daria

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #15234

    Hi Daria,
    Thank you for posting.

    It is very easy to filter member directories or any member list using the member type. So, restricting the users to their member type will be easy.

    The problem will be filtering activity based on member type. There is no available API. It will need to be done by filtering on activity query conditions(still doable). If you have large number of users in each reason, the overhead may not be justified.

    Another approach I see is using BuddyPress on Multisite with Multi Network. In that case activity/groups/posts/media etc separation will happen out of the box.

    Restring the users to their reason will also be easy.

    Regards
    Brajesh

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

    Hi Brajesh,

    Thanks for the advice, I will have to look into it and see what seems the best option is best for me.

    Daria

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

    Hi Brajesh,

    I recently bought your plugin Member Types Pro and decided to go with one site route vs Multisite. It seems to work well so far and I was also able to organize my members into Men and Women so they display separately on custom members page, which is nice.

    Can you point me in your documentation how to hide certain member types from the other member types in the directory. I can’t seem to find it, I only see info the hide content, not members. Or does that mean I need two separate directory pages. Please advise.

    Thank you

    Daria

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #18209

    Hi Daria,
    Thank you for purchasing the plugin. I am glad the multisite route is working.

    At the moment, exclusion can be enabled by code. If you want, I can post the code. I am also going to add the feature in the member types pro plugin in next 2-3 days(at most by the end of the day 26th October).
    If you need it today, please let me know and I will share the code.

    Thank you
    Brajesh

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

    Hi Brajesh,

    Sorry, I went with single site, not multi.

    Can you send me the code so I can play with it next few days and see how it works. And then I will disable it when your update comes out. Thank you.

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #18215

    Hi Daria,

    Thank you for clarifying. Good to know that.

    You can use the following code in bp-custom.php or in your theme’s functions.php

    
    
    /**
     * Restrict members list by member type.
     *
     * @param array $args args.
     *
     * @return array
     */
    function buddydev_filter_by_opposite_member_type( $args ) {
    
    	//  No need to change members listing if the user is not logged in.
    	if ( ! is_user_logged_in() ) {
    		return $args;
    	}
    
    	// Map of visible member types based on the member type.
    	// 'male', 'female' are member type names.
    	$visible_types_map = array(
    		'male'   => 'female',
    		'female' => 'male',
    	);
    
    	$member_type = bp_get_member_type( get_current_user_id(), true );
    
    	// If the user does not have a member type
    	// or if the user does not need the restriction.
    	if ( empty( $member_type ) || empty( $visible_types_map[ $member_type ] ) ) {
    		return $args;
    	}
    
    	$args['member_type'] = $visible_types_map[ $member_type ];
    
    	return $args;
    
    }
    
    add_filter( 'bp_after_has_members_parse_args', 'buddydev_filter_by_opposite_member_type' );
    

    You may want to change the visible map based on the name of your member types.

    It maps member type of the current user to the member type whose users will be visible to them.

    Regards
    Brajesh

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

    Hi Brajesh,

    Thanks! I’m glad I tested it out and it works in essence but I have further requests/questions. Can you see if you can help me with this – is this even possible.

    • I am currently filtering out like this:
    // Map of visible member types based on the member type.
    // ‘male’, ‘female’ are member type names.
    $visible_types_map = array(
    ‘international’ => ‘international’,
    ‘usandcanada’ => ‘usandcanada’,
    );

    But, my members also have a secondary member type Man and Woman. Is it possible to have this condition specify to show only members to International that have “international, man” and “international, woman”. So it hides “uscanada, man” and uscandcanada, woman”. Basically they have to meet those two conditions to show and hide. And vice versa. Does it make sense?

    • Also, on /members page the members are filtered out but if the International member clicks on Groups or Activity, and they select a member, they can click on that person’s profile and contact them. Which makes the whole hiding of directory pointless. Can we add a filter so they can’t see the profile when they click on it? A message that says, “You have no access to this profile”, something like that. And not allow to message and add a friend. Is that doable? I don’t mind if they see that person’s thumbnail in activity or Group. Just no contact options.

    If you could make this work, it would be great, if not, then maybe the filtering won’t work and I have to have them all together in one bucket. US and Canada is my main market and I want to keep it separate if possible.

    Thank you

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #18240

    Thank you Daria,
    It is doable but will need changes in code. I will test a bit today and then post the code.

    Regards
    Brajesh

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

    Great, thanks Brajesh. I appreciate this.

You must be logged in to reply to this topic.

This topic is: not resolved