Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use user ids resulting from custom query by pmpro_members_list_s… #2811

Merged

Conversation

rollsappletree
Copy link
Contributor

@rollsappletree rollsappletree commented Feb 5, 2024

…ql filter

All Submissions:

Changes proposed in this Pull Request:

Using pmpro_members_list_sql filtered query to actually generate the CSV to.
I implemented a custom query (with other filters based on user meta) using the pmpro_members_list_sql filter.
I can see the users by the filters I setted in the membership table via UI. If I click the export csv button, the code actually use the custom query to generate an array of users, and then it uses "between" with those array.

If the users are not consecutives, the member UI data and the one extracted via CSV are not equal.
With this change it'll be the same.

How to test the changes in this Pull Request:

  1. go to the membership page
  2. create some new filters and implement it via pmpro_members_list_sql
  3. try to download CSV

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you successfully run tests with your changes locally?

Changelog entry

Enter a summary of all changes on this Pull Request. This will appear in the changelog if accepted.

@dparker1005
Copy link
Member

This PR breaks the assumption that $theusers (an array of user IDs to output) is ordered. This may be the case if the ORDER BY statement is altered by the pmpro_members_list_sql filter to show data in a custom order.

To break the assumption that $theusers is in order, this PR switches from querying between a set of user IDs to splicing the $theusers array to get the specific user IDs to show during each iteration. This is much safer to avoid duplicate and missing records in cases where pmpro_members_list_sql is out of order.

@ideadude ideadude merged commit 839a898 into strangerstudios:dev Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants