Dave McCourt thinks some thoughts...

Setting last login times for WordPress users

Posted in: Code snippets, WordPress
Requires Advanced Custom Fields
<?php
function banana__set_last_login($login) {
        
    $user = get_user_by('login', $login);
    $login_time = date('Y-m-d H:i:s');
    $client_ip = get_client_ip();
    $repeater_field_key = 'your_ACF_repeater_field_key';

    if (have_rows($repeater_field_key, 'user_' . $user->ID)) :
        $value = get_field($repeater_field_key, 'user_' . $user->ID);
    else :
        $value = array();
    endif;
    
    $value[] = array('your_ACF_sub_field_key1' => $login_time, 'your_ACF_sub_field_key2' => $client_ip);
    update_field($repeater_field_key, $value, 'user_' . $user->ID);
    
}
?>