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

Search only sorts by first name #1103

Open
stevenwolock opened this Issue Jun 5, 2017 · 18 comments

Comments

Projects
None yet
4 participants
@stevenwolock
Copy link

stevenwolock commented Jun 5, 2017

EXPLANATION OF THE ISSUE

Search only sorts by first name

STEPS TO REPRODUCE THE ISSUE

Visit this page. This is a brand new, clean install with no additional plugins. You'll see a list of therapists ordered by last name. Enter a state in the search field. The list is now sorted by first name and not last name as expected.

BEHAVIOR THAT I EXPECTED

The shortcode is [s2Member-List enable_list_search="yes" orderby="last_name" order="ASC" show_fields="state_province, ID"/]. I would expect that a search would return the results ordered by last name because because orderby="last_name" is in the shortcode.

I did import the S2member configuration and users from the live website so I suppose it's possible the problem moved with that.

BEHAVIOR THAT I OBSERVED

@stevenwolock

This comment has been minimized.

Copy link

stevenwolock commented Jun 6, 2017

I added an even more bare bones site, still the same behavior. I sent login info to support@wpsharks.com subject 'Orderby with Search Not Working'. Sorry if I'm sending duplicate info. I hadn't heard from support until after I posted the bug report.

@renzms

This comment has been minimized.

Copy link
Contributor

renzms commented Jun 8, 2017

@stevenwolock

Hi Steven, for personal details such as login info, etc you can continue sending those in the email support thread you have open with us.

We will attempt to reproduce this issue in a clean installation and add the findings in this GitHub Issue.

@stevenwolock

This comment has been minimized.

Copy link

stevenwolock commented Jun 8, 2017

Thank you for taking a look at this. I don't know how to use Github, so pardon me if I should have provided this info in a different way.

Here's the template member-list.php.zip for https://sstarnet.org/find-a-researcher/ . I really don't think it's that because the following clean installations use the default template and you'll see the same results.

I'll email the login credentials for these tests again. They all use the same credentials.

NOTE: To try to rule out a hosting issue, the above clean installations are hosted at Siteground. The original website, sstarnet.org, is hosted at GoDaddy.

Also, https://sstarnet.org/find-a-researcher/?s2-s=Home sorts by first name when searched. I haven't changed any parameters at all so I don't know what you saw the first time.

Please let me know if there's anything I can do to help.

Thanks again for helping with this issue.

Steve

@renzms

This comment has been minimized.

Copy link
Contributor

renzms commented Jun 9, 2017

Status: Unable to Replicate Issue

Was unable to reproduce original issue on clean installation.

Tested Using:

WordPress Version: 4.8-RC2-40880 / WordPress 4.7
Current WordPress Theme: Twenty Seventeen version 1.2
Active Plugins: s2Member Framework Version 170524 + s2Member Pro v170524
PHP Version: 7.1.3-3+deb.sury.org~xenial+1
MySQL Version: 10.0.29-MariaDB-0ubuntu0.16.04.1

cc: @raamdev / @jaswrks


Hi @stevenwolock

Tested the exact same shortcode you had used:

[s2Member-List enable_list_search="yes" orderby="last_name" order="ASC" show_fields="state_province, ID"/]

with the addition of adding of using exclude="1" to remove admin user.

test shortcode

Front End test for [s2Member-List /]:

test

As you can see, the names are listed in ascending order (alphabetical order) by last name.

@stevenwolock wrote:

https://river-graphics-design.net/sstar/ I imported users and S2Member config.
https://river-graphics-design.net/sstar2/ I imported only users, not the S2Member config file.
https://river-graphics-design.net/sstarr3/ I used everything fresh. First I used the current version of S2Member. Then to see if it's an update issue, I used version 170221 and then version 161129. Still no luck.

Those also show a listed ascending order by last name. If you mean that they don't show the Last Name first, and actually want the last_name to display before the first_name, please create a custom template. Please see: https://s2member.com/kb-article/using-a-custom-template-for-s2member-list/

The display name is display_name, which is the full display name of the user, not two separate data fields: first_name last_name

Please refer to this line of code here

@stevenwolock

This comment has been minimized.

Copy link

stevenwolock commented Jun 9, 2017

Hi Renz,

Thanks again for your help with this issue.

However, I don't see a search field in your screen shots. The problem does not occur when the page first loads. The problem occurs only when the page is searched from the search box. Your code above does not include the shortcode [s2Member-List-Search-Box placeholder="Search"/] for a search box.

As I have mentioned, everything is fine with simply loading the page, as your test affirms. The problem only occurs when a search is executed.

@stevenwolock

This comment has been minimized.

Copy link

stevenwolock commented Jun 9, 2017

@renzms

This comment has been minimized.

Copy link
Contributor

renzms commented Jun 12, 2017

@stevenwolock

I've included a search box and was unable to replicate your original error consistently based only off of Display Names / First / Last:

Click for Search Results Page

The names would always be alphabetical order in first couple of tests:

Hero List


However, I continued to experiment to try and replicate your original error. I was able to replicate it more consistently when I included usernames that were not based off of their names.

For Example:

Click for Search Results Page

Search results ordered by Username:

First Name Last Name Username State
Hank Pym Antman New York
Steve Rogers Captain America New York
Charles Xavier Prof X New York
Peter Parker Spidey New York

Search Results:

New York Heroes

The Usernames are sorted in Alphabetical order despite having set it to sort by Last Name, (orderby="last_name" order="ASC" ).


On your search page https://river-graphics-design.net/sstar/?s2-s, the results look like they are being sorted by First name, but that could be the result of the Username being based off of their First and Last name.


Status : Bug Found

Search list results sort order by set username, not by set search parameter in shortcode, in this case: orderby="last_name" order="ASC"

cc: @raamdev / @jaswrks

@stevenwolock

This comment has been minimized.

Copy link

stevenwolock commented Jun 12, 2017

Thanks for continuing to explore this issue. Can you please respond to/confirm the following so I can relay this info to my client?

  1. You have confirmed that a bug has been identified.
  2. The sort is happening by username even though the shortcode specifies last_name.
  3. Is there a fix, workaround, or patch for this issue?
  4. What is the next step?

Thanks again.

@wpsharks wpsharks deleted a comment from stevenwolock Jun 13, 2017

@raamdev

This comment has been minimized.

Copy link
Contributor

raamdev commented Jun 14, 2017

I've also been able to reproduce this issue, although I'm not 100% sure that it's a bug and not just unnecessarily confusing.


Steps to Reproduce the Issue

  1. Create a page with the following:
[s2Member-List-Search-Box /]
[s2Member-List enable_list_search="yes" orderby="last_name" order="ASC" /]
  1. Ensure that you have at least two users with different last names and different usernames (in my example, I'm using "Raam Dev" raamdev, and "Example User" example).

  2. Load the page with the [s2Member-List /] shortcode and observe that the order is (correctly) sorted by last name (orderby="last_name") in ascending order (order="ASC"):

    2017-06-14_16-46-23

  3. Now do a search that will result in the same list of users appearing in the results. In my case, both users have an email address that has raam in them, so I'll do a search for raam. Note how the results are no longer sorted by last name (orderby="last_name") in ascending order (order="ASC"); instead the order of the results appears to be sorted by username (orderby="username"):

    2017-06-14_16-47-03


I'm not sure if this is because the orderby="last_name" and order="ASC" attributes are not supposed to apply to the search results, or if there's actually a bug here that's preventing that from working as expected.

@jaswrks we could use some clarification from you here when you get a chance.

@jaswrks

This comment has been minimized.

Copy link
Contributor

jaswrks commented Jun 15, 2017

@stevenwolock @renzms @raamdev

Nice find. Yep, that's a confirmed bug. Thank you for reporting this.


Referencing: https://github.com/websharks/s2member-pro/blob/170524/src/includes/classes/member-list.inc.php#L110-L135

And this line, where we need to merge the dummy meta keys so that WP_User_Query is capable of sorting by last_name whenever a search is being performed. See: https://github.com/websharks/s2member-pro/blob/170524/src/includes/classes/member-list.inc.php#L256

@jaswrks

This comment has been minimized.

Copy link
Contributor

jaswrks commented Jun 15, 2017

A short-term workaround is to set orderby="display_name"

@jaswrks

This comment has been minimized.

Copy link
Contributor

jaswrks commented Jun 15, 2017

What happens currently is that results are ordered by user User ID in this buggy scenario.

@stevenwolock

This comment has been minimized.

Copy link

stevenwolock commented Jun 15, 2017

Thanks @renzms, @raamdev, and @jaswrks for pursing this issue. Sorry but I don't see how orderby="display_name" is short-term workaround.

display_name uses the first name and last name as a string. So Aaron Marsh comes before Abby Girard. Here's a screenshot without a search ordered="display_name".
image

Additionally, it looks to me like the sort order is by display_name when a search is done, not by ID. Here's a screenshot sorted on New York. You'll see that the IDs are not in order and it appears to be sorted by first name then last name.
image

Thanks again

@stevenwolock

This comment has been minimized.

Copy link

stevenwolock commented Jun 15, 2017

@jaswrks I'm not familiar with procedures for addressing bugs. Do you know if this will be addressed in the next update? I'm sure my client is going to ask. Thanks

@raamdev raamdev assigned jaswrks and unassigned renzms Jun 15, 2017

@stevenwolock

This comment has been minimized.

Copy link

stevenwolock commented Jun 26, 2017

Reminder about previous comment...

@stevenwolock

This comment has been minimized.

Copy link

stevenwolock commented Jul 24, 2017

Is this issue resolved in the new update v170722?

@raamdev

This comment has been minimized.

Copy link
Contributor

raamdev commented Jul 28, 2017

@stevenwolock No, it has not been resolved yet. You can see the changelog here: https://s2member.com/changelog

We don't have an ETA on when this will be resolved at this time, but we hope to get it out with the next release.

@stevenwolock

This comment has been minimized.

Copy link

stevenwolock commented Dec 12, 2017

Hi S2 Member gang... any updates on this issue? I know my client is going to be asking any day now. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment