BuddyDev

Search

BuddyPress Member Types Pro – Looking for REST API end points

  • Participant
    Level: Enlightened
    Posts: 35
    Mical Johnson on #28431

    Hi Brajesh,

    Hope you’re doing well in this Corona world … Also, awesome job with this plugin my friend! For your plugin my project is now being possible.

    I’m having to write a Global Search portal using the REST API. I’ve looked into BP REST stuff, which is great but wondering if this plugin has some REST endpoints I can use to narrow down the search to just one type of member and their custom fields. I’m using one of your plugins for those advanced fields by the way(thanx again). Could you plz help?

    Plz, let me know if you have some custom REST endpoint. Sooner the better. Thanx in advance.

    On behalf of Mical
    Moose (the dev)

  • Keymaster
    (BuddyDev Team)
    Posts: 24212
    Brajesh Singh on #28435

    Hi Moose,
    Thank you for using our plugin.

    BuddyPress offers members endpoint and you can filter the list by member type(This is supported by BuddyPress core out of the box).

    Please see
    https://github.com/buddypress/BP-REST/blob/master/includes/bp-members/classes/class-bp-rest-members-endpoint.php

    regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 35
    Mical Johnson on #28443

    Sorry, Brajesh,

    the file you referred to isn’t helping me … I was hoping more like usage link like this:

    https://asm-poc.cyberizegroup.com/wp-json/buddypress/v1/members

    More like how to use the member type in the REST url to get an isolated result … for example,

    I have 2 types of members 1) athlete & 2) coach and athletes have xprofile field for ‘Choose Your Sports’ with value ‘US FOOTBALL’ so, is there a way to have a REST link to isolate a list of members that are Athletes that plays US FOOTBALL?

    
    "49": {
    "name": "Choose Your Sport",
    "value": {
    "raw": "US FOOTBALL",
    "unserialized": [
    "US FOOTBALL"
    ],
    "rendered": "<p><a href="https://asm-poc.cyberizegroup.com/members/?members_search=US+FOOTBALL" rel="nofollow">US FOOTBALL</a></p>
    "
    }
    }
    

    So far I tried this:

    
    https://asm-poc.cyberizegroup.com/wp-json/buddypress/v1/members?member_type=athlete&search=football
    

    Well, I managed to isolate to Athlete member type, but I cannot get the correct sports name without narrowing down to proper xprofile field …

    I know it’s a lot to ask, but I’m desperate … there is no help out there on this … If you could help me with this I’d be grateful for life …

    Thanx a lot in advance.

    Moose

  • Participant
    Level: Enlightened
    Posts: 35
  • Keymaster
    (BuddyDev Team)
    Posts: 24212
    Brajesh Singh on #28447

    Hi,
    You can specify member type on the same end point as members(You already did).

    Please see the endpoint docs for details.

    https://developer.buddypress.org/bp-rest-api/reference/members/

    You can specify multiple member types too.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 35
    Mical Johnson on #28471

    Thankyou Brajesh,

    That helped a lot and I am pretty close. And I think I found the reason why I’m getting wrong results with this:

    https://asm-poc.cyberizegroup.com/wp-json/buddypress/v1/members?member_type=athlete&search=FOOTBALL

    I just checked and found that somehow the plugin is adding extra member_types like this:

    
    "member_types": [
    "american-football",
    "american-football-athletes",
    "athlete"
    ],
    

    You see, the only way I’m creating member types is through your plugin. And only 2 member types of members I added are “athlete” and “coach”. So can you plz tell me how those other member types got in there? At least can you guide me in the right direction? Cuz those extra member types were never meant to be in there. Why the system is doing that and how? Any idea? I’d appreciate any insight you may wanna share and how to fix this. Thanx in advance.

    Moose

  • Keymaster
    (BuddyDev Team)
    Posts: 24212
    Brajesh Singh on #28472

    Hi Moose,
    Thank you.

    I am assuming it is added by some custom code or plugin you are using(Member types can be added by code directly too).

    Can you please visit Dashboard->Users and from the member type dropdown check which member types are available?

    Are they reflecting only registered by member types pro plugin or are they reflecting the others too?

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 35
    Mical Johnson on #28513
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 24212
    Brajesh Singh on #28515

    Hi Moose,
    I had a look and I can confirm that you have only 2 member types.

    As I can see from the result in your previous reply that the member type for a user is showing some types which are not even available.

    Is there any chance you had created member types with these names earlier and later renamed?

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved