BuddyDev

Search

Assign Member Type based on BuddyPress xProfile field value

  • Participant
    Level: Enlightened
    Posts: 60
    lavish on #5061

    Hi!

    I have finally installed ‘BuddyPress Member Type Generator Plugin’ to me site. I have to assign Member Type to over 4,000 existing members.

    The problem is, I have to give different Member Type to ‘male’ and ‘female’ members. So, bulk assigning the member type will be a big task if I have to tick members one by one.

    Is there a way to assign Member Type depending on xProfile field value?

    Thank you for the help 🙂

  • Keymaster
    (BuddyDev Team)
    Posts: 22213
    Brajesh Singh on #5077

    Hi Lavish,
    If it is just 4000, you can do it via a loop or db query. I will try and see if I can do something with the DB Queries.

    Please provide me following:-
    1. Male/female Xprofile field value . It is case sensitive. So, please let me know what have you used

    2. The unique slug for male/female member type.

    Thank you
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 60
    lavish on #5088
    This reply has been marked as private.
  • Participant
    Level: Enlightened
    Posts: 60
    lavish on #5089

    I have a few question too. It will be so kind of you if you please answer :

    1 – Will your loop or db query affect the existing members only? I hope so because I will be inviting a new lot of people to join my site. These people will be registering under yet another 2 new Member Types (already created). And the Male / Female field will be serving them too. So our loop / db query should not affect any future members.

    2 – Is there any way to hide certain member type(s) from member directory and searches performed by bp profile search plugin? I by the way use an old code provided by you to hide certain members. I still use it to hide every member I want to hide. However, because now we can keep all such members in a Member Type, I thought you may suggest a different code.

    3 – Is there a way to show Member Type under avatar in bbPress replies?

    I have a few ideas too to share, please let me know if I should share.

    Thank you again

  • Keymaster
    (BuddyDev Team)
    Posts: 22213
    Brajesh Singh on #5146

    Hi Lavish,
    1. No
    2. Yes, I will post a tutorial this week
    3. yes, Please find the code below.

    
    
    function buddydev_update_forum_display_role( $role, $user_id ) {
    
    	$member_type = bp_get_member_type( $user_id, true );//please fetch only one
    
    	if( $member_type ) {
    		$role = $role .'/' . $member_type;
    	}
    
    	return $role;
    
    }
    
    add_filter( 'bbp_get_user_display_role', 'buddydev_update_forum_display_role', 200, 2 );
    
    

    Hope that helps.

  • Participant
    Level: Enlightened
    Posts: 60
    lavish on #5240

    Hello Brajesh!

    1 – I tried the above code, it did not work for me. I then used a plugin to show the Member Type field instead. It’s showing the actual ‘member type slug’ which is in small letters. For example it can show ‘student’ and not ‘Student’.

    2 -I am waiting for the code to exclude certain member types from directory, searches and searches by ‘bp profile search plugin’.

    3 – I am learning things using the ‘Member Type Generator plugin’ and I have learned that <b>I need some Member Types to be only assigned manually by the admin. If I give the users the option to choose the member types on registration, how do I exclude some member types from that drop down list?

    Thank you again

  • Participant
    Level: Enlightened
    Posts: 60
    lavish on #5476

    ‘2. Yes, I will post a tutorial this week – quote from above’

    Hello @sbrajesh can you please help me with the code now? I want to hide certain member type(s) from member directory and searches performed by bp profile search plugin. There profiles should be accessible but invisible in listings and searches.

    Thank you 🙂

You must be logged in to reply to this topic.

This topic is: not resolved