Add Appt User Dropdown not ordered properly

Hey There,

I am trying to manually add an appointment in the WP admin dashboard. When I select the dropdown for current users the list of users is not in a particular order.

The first bunch is random emails and the remaining list seems to be in order with a mix of emails and usernames.

How can I get the entire dropdown list to display the emails in alphabetical order?

  • Adam Czajczyk

    Hey Judah,

    I hope you're well today and thank you for your question!

    I just checked it on my own setup and the user drop-down list on "Appointments" -> "Add new" page is displaying users in an alphabetical order for me. That being said I've noticed that you're using an older version of the plugin.

    I took a look at plugin's changelog and it seems that since then there has been a fix applied that may affect this. Could you please upgrade it then?

    If it doesn't help, please check if there are no users that used their e-mails as usernames (logins). Let me know please and if there'll still be an issue after upgrade, could you please let me take a look around your site?

    To do this, please follow this guide:
    https://premium.wpmudev.org/manuals/wpmu-dev-dashboard-enabling-staff-login/

    Cheers,
    Adam

  • Judah

    Hey @Adam Czajczyk,

    Thank you for getting back to me so quickly.

    I am testing this out on the newest version of A+ on a local site.

    I can confirm it is still not displaying properly.

    As for the usernames/emails- we are not using the username field for users to sign up. When they register they provide their email address and use that to login. For WP to understand that we automatically create a username for each person based on the their first name + random string of characters.

  • Adam Czajczyk

    Hey Judah,

    Thanks for the information.

    As for the usernames/emails- we are not using the username field for users to sign up. When they register they provide their email address and use that to login. For WP to understand that we automatically create a username for each person based on the their first name + random string of characters.

    I think this may be the point here. This is quite an uncommon setup and it's very likely that the Appointments+ plugin isn't handling it properly. Would it be possible for me to take a closer look at it via our WPMU DEV Dashboard? If you've any staging site with a setup like this and some example users (created the same way as you described) it would be great.

    Here's a handy guide on granting an access to the site:
    https://premium.wpmudev.org/manuals/wpmu-dev-dashboard-enabling-staff-login/

    Cheers,
    Adam

  • Judah

    Hey @Adam Czajczyk

    I do not have a staging site or example users.

    I do all the changing/testing locally and push it all up to the live site when it works and there are no bugs.

    As for the non use of usernames - from a DB perspective the column still exists and is being populated for each user. Not sure why A+ would care if a user signs in with an email or a username.

    I have just allowed access.

    Please let me know if you have any questions.

    Thanks,
    Judah

  • Adam Czajczyk

    Hey Judah!

    Thanks for granting access and additional explanation.

    I checked the page and took a look at user list as well.

    As for the non use of usernames - from a DB perspective the column still exists and is being populated for each user. Not sure why A+ would care if a user signs in with an email or a username.

    The issue here is that Appointments+ plugin "Add new" module is using "Username" to populate the drop-down list of users. In case of your setup this DB column is a mix of e-mail addresses and "normal" usernames. Therefore the sorting feature doesn't work properly.

    I've found out that the call for drop-down user list inside Appointments+ is explicitly set to use "user_login". Unfortunately, applying WP filter to this call results in making a plugin hung. That said, I'm calling a developer for help here.

    Please note though that their response time might be a bit longer than main here on forum. Please keep an eye on this thread then for further updates and information!

    Cheers,
    Adam

  • Adam Czajczyk

    Hey Judah!

    We avoid suggesting changes directly in plugins code unless there's no other way (which is a very rare scenario). However, if you're wishing to give it a try the line is inside the "appointments.php" file inside plugin's folder, around line #6502:

    $html .= wp_dropdown_users( array( 'show_option_all'=>__('Not registered user','appointments'), 'show'=>'user_login', 'echo'=>0, 'selected' => $app->user, 'name'=>'user' ) );

    Replacing it with the following should help, unless users' "display names" are also set by default to be the same as users's logins.

    $html .= wp_dropdown_users( array( 'show_option_all'=>__('Not registered user','appointments'), 'show'=>'display_name', 'echo'=>0, 'selected' => $app->user, 'name'=>'user' ) );

    Please note though that this change is based on the latest version of the plugin so you may need to update Appointments+ first. The changes will also be lost upon any future updates.

    Cheers,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.