Skip to:
Content
Pages
Categories
Search
Top
Bottom

Buddypress: Remember pagination for Membersloop in URL


  • sx1001
    Participant

    @sx1001

    How to remember the currently opened page in the pagination of the membersloop in Buddypress, so when visiting a profile and coming back to the membersloop, it gets opened on that page?

    I saw that in buddypress-nouveau.min.js?ver=1.7.8:formatted the ajax call is done via the JS function objectRequest() but it gets called with the “page: 1” parameter as a fixed value.

    Is there a way to override this?

Viewing 2 replies - 1 through 2 (of 2 total)

  • semmtex
    Participant

    @semmtex

    Did you ever work out a fix for this?

    Having the exact same problem and would love to know how to fix it.


    t.schwarz
    Participant

    @tschwarz-1

    This is how I got this done after serious research…

    This goes into your main js – source partly: https://support.themosaurus.com/forums/topic/add-a-pagination-on-top-of-buddypress-member-list/

    
    //add history state
    jQuery(document).on("mouseup touchend", ".bp-pagination a.page-numbers", function () {
       history.pushState({}, "Member directory - Page " + jQuery(this).text(), jQuery(this).attr("href"));
    });
    
    if (jQuery('body').hasClass('directory members')) {
       const params = new Proxy(new URLSearchParams(window.location.search), {
          get: (searchParams, prop) => searchParams.get(prop),
       });
       let value = params.upage; // upage being the passed pagination value
    
       var myCustomQueryData = {
         object: 'members',
         page: value || 1
       };
       
       bp.Nouveau.objectRequest(myCustomQueryData);
    }
    

    Hope this helps

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar