Trying to get the last login of each user and display it into the admin panel. Currently I can display the first user within the admin loop, however I can't pull out the remaining users.
I think I need to loop through and pull out each user meta_value where it's equal to last_login but I've tried a standard query and its not working. Code is:
function modify_user_column( $column_name, $user_id ) {
//get current user object
$current_user = wp_get_current_user();
if( 'last_login' != $column_name ) {
return get_last_login( $current_user->ID );
}
}
add_action( 'manage_users_custom_column', 'modify_user_column', 10, 2 );
And get_last_login() is:
function get_last_login($user_id) {
$last_login = get_user_meta($user_id, 'last_login', false);
$last_login = get_user_meta($user_id, 'last_login', true);
$date_format = get_option('date_format') . ' ' . get_option('time_format');
$the_last_login = mysql2date($date_format, $last_login, false);
return $the_last_login;
}
Thanks