The use of $show_login_records as a global variable seems inadequate. I have it set in the Settings, yet when I log in and try to display the value in the last_login function, it shows as false.
I think there is another problem with the plugin. This query:
$user_query = new WP_User_Query( array( 'meta_key' => 'when_last_login_count', 'meta_value' => 0, 'meta_compare' => '!=', 'order' => 'DESC', 'orderby' => 'meta_value', 'number' => 3 ) );
seems to assume that the values are stored as numbers, which does not seem true in my case, as 9 comes before 62 for instance.
meta_value_num should be used instead of meta_value.
Please fix.
Also not understanding why the multisite order is ASC, whereas the single site order is DESC. Shouldn’t they both be DESC?
Hi @chamois_blanc,
Thank you for using When Last Login.
The AJAX login should work as long as it runs through the wp_login hook. I will run some tests with that plugin and recreate the issue you are facing.
Regarding the other code questions, there are some issues with the code which we’ve started working on in fixing. These are some minor bugs and I do believe we could handle the global variable better.
If you would like to contribute to When Last Login, please feel free to submit a Pull Request to our Github Repository found here (it would help us release our next version quicker) – https://github.com/andrewlimaza/when-last-login
Thank you for your understanding.
I have just tested this with the Login With Ajax plugin and it’s capturing the login timestamps correctly.