BP Profile Search › Member type directories
-
AuthorPost
-
Henry Wright
GuestHi Andrea,
I’ve created 2 member types using the BuddyPress Member Type API. Each member type has a directory. For example:
- example.com/members/type/students
- example.com/members/type/teachers
I’m outputting a different form in each directory using a template tag.
When a user submits a form, they are taken to a results page at example.com/members. Does BP Profile Search allow me to use the member type directory as the results page.
For example, User A submits Form 1 on page:
example.com/members/type/students
Results are displayed at:
example.com/members/type/students
andrea
Plugin AuthorHi Henry,
Sorry for the late reply!
It should work as you expect but, if that’s not the case, please let me know.
Henry Wright
GuestIt should work as you expect but, if that’s not the case, please let me know.
When I submit the form at example.com/members/type/student, I always seem to be redirected to example.com/members page to view results.
andrea
Plugin AuthorHello Henry,
If your search form is in a widget, it always redirects to the example.com/members page.
At this moment possible workarounds are:
1) you could change the form action attribute in the form template, or
2) you could use the hook bps_search_form_data to change the $F->action value, which will then be used by the form template as the form action attribute.
Henry Wright
GuestThanks for pointing out
bps_search_form_data
. I think the issue I’m seeing is related to me using a shortcode to output the form. In my case, I noticed the$F->location != 'directory'
condition inside bps-form-sample-1.php always sets form action to “shortcode”.Here’s the fix I ended up with:
add_filter( 'bps_search_form_data', function( $F ) { switch ( buddypress()->current_member_type ) { case 'student': $F->location = 'directory'; break; default: // Do nothing for now. } return $F; } );
Thanks again for pointing me in the right direction.
andrea
Plugin AuthorHello Henry,
Thank you for your feedback and code. I’ll try to add support for member type directories directly in BP Profile Search.
Henry Wright
GuestYou may be able to do something as simple as:
if ( buddypress()->current_member_type ) { // Set location to "directory" }
andrea
Plugin AuthorHello Henry,
I’ve just released BP Profile Search 4.6.1, to support member type directories.
Would you like to test it?
Henry
GuestThank you Andrea, I’ll give it a try this week and report back if I find any issues.
Andrew
GuestHi! Great plugin – so far it is exactly what I am looking for…. though I’d like to add a few tweaks to it.
I’ve chosen this thread simply because it seems to be the closest match to what I am trying to accomplish.
I have been trying to sort out a few things such thatA. Removing the the total amount of users box above search results
B. Trying to have it only show “members” holding “contributor” roles in search results.
I have tried to add code mentioned above…
add_filter( 'bps_search_form_data', function( $F ) { switch ( buddypress()->current_member_type ) { case 'Single State Membership': $F->location = 'directory'; break; default: // Do nothing for now. } return $F; } ); and
add_filter( ‘bps_search_form_data’, function( $F ) {
switch ( buddypress()->current_member_type ) {
case ‘Membership Plus’:
$F->location = ‘directory’;
break;
default:
// Do nothing for now.
}
return $F;
} );and I don’t think I am entering it in the right place or how this should be done. As it is still giving ‘All’ types …
Please help – Thank you
Andrewandrea
Plugin AuthorHi Andrew,
Sorry for the late reply!
For point A, you have to modify the BuddyPress template for the Members directory.
For point B, you could use the plugin:
https://buddydev.com/plugins/bp-pseudo-role-field/
that adds the user role as a search field.
Tejas
Guesthow can I add member directories in the function can you help me out?
andrea
Plugin AuthorHi Tejas,
You can find a good description here:
-
AuthorPost