diff --git a/inc/helpers/aksrt-user-dashboard.php b/inc/helpers/aksrt-user-dashboard.php index e68bdd9e..30811c14 100644 --- a/inc/helpers/aksrt-user-dashboard.php +++ b/inc/helpers/aksrt-user-dashboard.php @@ -106,3 +106,16 @@ function aksrt_get_user_dashboard_view(int $user_id, array $args = []): array { 'is_own_profile' => $is_own_profile, ]; } + +add_action('wp_login', static function ($user_login, $user = null): void { + $user_id = 0; + if ($user instanceof WP_User) { + $user_id = (int) $user->ID; + } elseif (is_string($user_login) && $user_login !== '') { + $found = get_user_by('login', $user_login); + $user_id = $found instanceof WP_User ? (int) $found->ID : 0; + } + if ($user_id > 0) { + update_user_meta($user_id, 'aksrt_last_login', time()); + } +}, 20, 2); diff --git a/templates/parts/user/author-hero.php b/templates/parts/user/author-hero.php index a4520cc9..aa61a295 100644 --- a/templates/parts/user/author-hero.php +++ b/templates/parts/user/author-hero.php @@ -38,9 +38,12 @@ $show_desc = !array_key_exists('desc', $settings) || !empty($settings['desc']); $show_message = !array_key_exists('message', $settings) || !empty($settings['message']); $profile_details = is_array($dashboard['profile_details'] ?? null) ? $dashboard['profile_details'] : []; -// Gender is rendered inside the dialog but never creates a standalone menu -// action: without visible social details there is no "更多资料" item. -$has_more_details = !empty($profile_details['website']) || !empty($profile_details['qq']) || !empty($profile_details['wechat']) || !empty($profile_details['github']); +// Registration time is always present, so the details dialog always has +// content and the "更多资料" menu action is always available. +$registered_time = get_date_from_gmt((string) $user->user_registered, 'Y-m-d H:i:s'); +$last_login_ts = (int) get_user_meta($user_id, 'aksrt_last_login', true); +$last_login_time = $last_login_ts > 0 ? wp_date('Y-m-d H:i:s', $last_login_ts) : ''; +$has_more_details = $registered_time !== '' || $last_login_time !== '' || !empty($profile_details['website']) || !empty($profile_details['qq']) || !empty($profile_details['wechat']) || !empty($profile_details['github']); $signals = $dashboard['profile_signals'] ?? []; $notice = $dashboard['profile_notice'] ?? null; $show_report = !empty($dashboard['show_report']); @@ -197,6 +200,8 @@ $pm_url = ($pm_enabled && $messages_url !== '')
GitHub
QQ
+
+