Title: Only Logging Admin Logins
Last modified: May 15, 2018

---

# Only Logging Admin Logins

 *  Resolved [drcheap](https://wordpress.org/support/users/drcheap/)
 * (@drcheap)
 * [7 years, 12 months ago](https://wordpress.org/support/topic/only-logging-admin-logins/)
 * The plugin appears to only be tracking log-ins for admin accounts. All admin 
   accounts are tracked, but no other accounts.
    We use the standard wp-login interface
   for log-ins. Theme is Divi. We use S2Member for our paid membership management.
   Custom user types for membership do show up in the drop-down filters, but no 
   records appear for their login histories. Users who have standard “member” accounts
   similarly have no records for their login histories. If I change an S2Member 
   paid membership account to an Admin account, then admin-level logins are tracked
   and do appear in the records. When I change that account back to either “member”
   or so it’s S2Member custom membership type then any future logins do not appear.
   Past logins from when that was an admin account show up, but new logins as “member”
   or as a custom membership type are not being tracked. Thank you in advance for
   any help you can offer! We’re really hoping to be able to use this plugin to 
   track IP addresses that may be compromising member accounts. Ah, and just to 
   head-off the obvious: yes, we did check our display filters! =)
    -  This topic was modified 7 years, 12 months ago by [drcheap](https://wordpress.org/support/users/drcheap/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fonly-logging-admin-logins%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Plugin Author [Faiyaz Alam](https://wordpress.org/support/users/faiyazalam/)
 * (@faiyazalam)
 * [7 years, 12 months ago](https://wordpress.org/support/topic/only-logging-admin-logins/#post-10289104)
 * To reproduce the bug, I installed a fresh WP setup and S2Member plugin.
    I placed
   the following code in theme’s functions.php file:
 *     ```
       add_action('wp_login', 'on_login');
       function on_login($username) {
           var_dump($username);exit;   
       }
       ```
   
 * The above function is called only if I do admin login.
    It means there is bug
   in S2Member plugin. You should create support topic for S2Member.
 * Please check this similar issue:
    [https://wordpress.org/support/topic/not-loging-with-userpro-userultra-plugins/](https://wordpress.org/support/topic/not-loging-with-userpro-userultra-plugins/)
 * Thanks.
 *  Thread Starter [drcheap](https://wordpress.org/support/users/drcheap/)
 * (@drcheap)
 * [7 years, 12 months ago](https://wordpress.org/support/topic/only-logging-admin-logins/#post-10292529)
 * Thanks. I will check in with them and report back. I appreciate your work checking
   it out!
 *  [oyegigi](https://wordpress.org/support/users/oyegigi/)
 * (@oyegigi)
 * [7 years, 12 months ago](https://wordpress.org/support/topic/only-logging-admin-logins/#post-10296627)
 * [@drcheap](https://wordpress.org/support/users/drcheap/), I’m experiencing the
   same problem. Can you let us know what you hear from s2member?
 *  Thread Starter [drcheap](https://wordpress.org/support/users/drcheap/)
 * (@drcheap)
 * [7 years, 12 months ago](https://wordpress.org/support/topic/only-logging-admin-logins/#post-10296703)
 * Ok, so I have tried three different tracking plugins and all had the same problem.
   After a little discussion in the support forums for s2Member, here is what we
   discovered. The problem is caused by using the wp_login hook, which s2Member 
   or something else on my site is bypassing. If you change the wp_login hook to
   wp_authenticate in the tracking plugin, it should work. I found a different plugin
   that was recommended over on the s2Member forums and modified that plugin by 
   editing one line and now it is tracking fine.
 * If Faiyaz could point me to the right file and line to make the change in this
   plugin, I would be happy to give it a try and see if it works on this plugin 
   as well.
 * Here’s the thread on the s2Member support forums about it: [https://forums.wpsharks.com/t/s2member-login-does-not-trigger-wp-login-event/4498/11](https://forums.wpsharks.com/t/s2member-login-does-not-trigger-wp-login-event/4498/11)
    -  This reply was modified 7 years, 12 months ago by [drcheap](https://wordpress.org/support/users/drcheap/).
 *  Plugin Author [Faiyaz Alam](https://wordpress.org/support/users/faiyazalam/)
 * (@faiyazalam)
 * [7 years, 12 months ago](https://wordpress.org/support/topic/only-logging-admin-logins/#post-10297869)
 * [@drcheap](https://wordpress.org/support/users/drcheap/)
 * wp_login hook is fired after user is authenticated successfully.
    wp_authenticate
   hook is fired before authentication. So, it is not good idea to use this hook.
 * I have checked the code of S2Member and found that it is usign wp_login to redirect
   after login that is why my plugin does not work.
    For more info, you can see 
   this file: \wordpress\wp-content\plugins\s2member\src\includes\hooks.inc.php 
   LINE **125**: `add_action('wp_login', 'c_ws_plugin__s2member_login_redirects::
   login_redirect', 10, 2);`
 * To fix this you have to change priority from 10 to 0 (i.e. zero) in the following
   file:
    wordpress\wp-content\plugins\user-login-history\includes\class-user-login-
   history.php
 * LINE **177**:`$this->loader->add_action('wp_login', $user_tracker, 'save_user_login',
   10, 2);`
 * After this, my plugin code will be excuted before S2Member and it will work fine.
   
   Please make sure to check if S2Member plugin is working fine after doing change
   in my plugin file. You can also tell about this change to S2Member support so
   that they can tell you if there may be in conflict with the plugin.
 * Hope this help.
 * Looking forward to hearing from you.
    Thanks.
    -  This reply was modified 7 years, 12 months ago by [Faiyaz Alam](https://wordpress.org/support/users/faiyazalam/).
    -  This reply was modified 7 years, 12 months ago by [Faiyaz Alam](https://wordpress.org/support/users/faiyazalam/).
 *  [oyegigi](https://wordpress.org/support/users/oyegigi/)
 * (@oyegigi)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/only-logging-admin-logins/#post-10309708)
 * I just tried making this change and all appears to be working correctly with 
   site. I’ll give an update after a bit to see if it’s capturing data for users.
   Thanks!

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

The topic ‘Only Logging Admin Logins’ is closed to new replies.

 * ![](https://ps.w.org/user-login-history/assets/icon-128x128.jpg?rev=1886722)
 * [User Login History](https://wordpress.org/plugins/user-login-history/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/user-login-history/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/user-login-history/)
 * [Active Topics](https://wordpress.org/support/plugin/user-login-history/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/user-login-history/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/user-login-history/reviews/)

 * 6 replies
 * 3 participants
 * Last reply from: [oyegigi](https://wordpress.org/support/users/oyegigi/)
 * Last activity: [7 years, 11 months ago](https://wordpress.org/support/topic/only-logging-admin-logins/#post-10309708)
 * Status: resolved