Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

If I look at

/wp-admin/users.php

I see all the users, but some have given a bogus email and never used their password.

Is there some way to see who has used their password at least once? If not, is there a plugin to do this going forward?

share|improve this question
    
Are they activated? –  kaiser Feb 8 '13 at 20:08

2 Answers 2

up vote 1 down vote accepted

If you install the following plugin and leave that one running for a while... you can see who logged in since using that plugin:

http://wordpress.org/extend/plugins/wp-last-login/

enter image description here

That seems to do what you need.

As far as I quickly can see it runs on $this->hook( 'wp_login' ) and does:

$user   =   get_user_by( 'login', $user_login );
update_user_meta( $user->ID, 'last-login-in-meta-table', time() );

Possibly the

user-settings-time 

in the meta table can help somewhat on determining the history before installing the plugin, never used it (see http://wpseek.com/wp_user_settings/)

share|improve this answer
2  
It is possible because we can assign a Post to a User, but it's weird to have 21 Posts and never been logged in... –  brasofilo Feb 8 '13 at 20:37
1  
@brasofilo Didn't notice it, but made my day :) –  kaiser Feb 8 '13 at 20:38
    
I bet that guy is using XMLRPC ... –  edelwater Feb 8 '13 at 20:42
    
User logs in and posts many times, then you add this plug. Last logged in is "never." –  Yar Feb 9 '13 at 16:08

Login information like this is not stored anywhere in database. But you can add it for future users. Following code will check for current user meta user_login_count on each login and increase it by 1 or set it to '1' on first login.

<?php
add_action('wp_login', 'my_count_logins');
function my_count_logins() {
    $user_id = get_current_user_id();
    $user_login_count = (int) get_user_meta($user_id, 'user_login_count', true);
    if($user_login_count)
        $user_login_count++;
    else
        $user_login_count = 1;
    update_user_meta($user_id, 'user_login_count', $user_login_count)
}

Following code adds additional column Login count to the Users table:

function my_alter_user_table( $column ) {
    $column['user_login_count'] = __('Login count');
    return $column;
}
add_filter( 'manage_users_columns', 'my_alter_user_table' );

function my_alter_user_row( $val, $column_name, $user_id ) {
    switch ($column_name) {
        case 'user_login_count' :
            return get_user_meta($user_id, 'user_login_count', true);
        break;
        default:
    }
    return $return;
}
add_filter( 'manage_users_custom_column', 'my_alter_user_row', 10, 3 );
share|improve this answer
    
This is very cool, thanks! –  Yar Feb 9 '13 at 16:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.