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.

Reply to: Member type directories
My Information