Member type directories

BP Profile Search Member type directories

  • Author
    Post
  • #8594 Reply
    Henry Wright
    Guest

    Hi 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

    #8596 Reply
    andrea
    Plugin Author

    Hi Henry,

    Sorry for the late reply!

    It should work as you expect but, if that’s not the case, please let me know.

    #8601 Reply
    Henry Wright
    Guest

    It 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.

    #8602 Reply
    andrea
    Plugin Author

    Hello 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.

    #8603 Reply
    Henry Wright
    Guest

    Thanks 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.

    #8604 Reply
    andrea
    Plugin Author

    Hello Henry,

    Thank you for your feedback and code. I’ll try to add support for member type directories directly in BP Profile Search.

    #8605 Reply
    Henry Wright
    Guest

    You may be able to do something as simple as:

    if ( buddypress()->current_member_type ) {
        // Set location to "directory"
    }
    #8607 Reply
    andrea
    Plugin Author

    Hello Henry,

    I’ve just released BP Profile Search 4.6.1, to support member type directories.

    Would you like to test it?

    #8621 Reply
    Henry
    Guest

    Thank you Andrea, I’ll give it a try this week and report back if I find any issues.

    #8844 Reply
    Andrew
    Guest

    Hi! 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 that

    A. 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
    Andrew

    #8993 Reply
    andrea
    Plugin Author

    Hi 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.

    #12019 Reply
    Tejas
    Guest

    how can I add member directories in the function can you help me out?

    #12020 Reply
    andrea
    Plugin Author

    Hi Tejas,

    You can find a good description here:

    https://dontdream.it/bp-profile-search/custom-directories/

Reply to: Member type directories
My Information