更多资料新增元信息
This commit is contained in:
1 parent
54ee4b3bdd
commit
57b12dea80
2 files changed
+21
-3
No files matched your search
@@ -106,3 +106,16 @@ function aksrt_get_user_dashboard_view(int $user_id, array $args = []): array {
|
|||||||
'is_own_profile' => $is_own_profile,
|
'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);
|
||||||
@@ -38,9 +38,12 @@ $show_desc = !array_key_exists('desc', $settings) || !empty($settings['desc']);
|
|||||||
$show_message = !array_key_exists('message', $settings) || !empty($settings['message']);
|
$show_message = !array_key_exists('message', $settings) || !empty($settings['message']);
|
||||||
|
|
||||||
$profile_details = is_array($dashboard['profile_details'] ?? null) ? $dashboard['profile_details'] : [];
|
$profile_details = is_array($dashboard['profile_details'] ?? null) ? $dashboard['profile_details'] : [];
|
||||||
// Gender is rendered inside the dialog but never creates a standalone menu
|
// Registration time is always present, so the details dialog always has
|
||||||
// action: without visible social details there is no "更多资料" item.
|
// content and the "更多资料" menu action is always available.
|
||||||
$has_more_details = !empty($profile_details['website']) || !empty($profile_details['qq']) || !empty($profile_details['wechat']) || !empty($profile_details['github']);
|
$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'] ?? [];
|
$signals = $dashboard['profile_signals'] ?? [];
|
||||||
$notice = $dashboard['profile_notice'] ?? null;
|
$notice = $dashboard['profile_notice'] ?? null;
|
||||||
$show_report = !empty($dashboard['show_report']);
|
$show_report = !empty($dashboard['show_report']);
|
||||||
@@ -197,6 +200,8 @@ $pm_url = ($pm_enabled && $messages_url !== '')
|
|||||||
<?php if (!empty($profile_details['github'])) : ?><div><dt>GitHub</dt><dd><a href="<?php echo esc_url($profile_details['github']); ?>" target="_blank" rel="noopener noreferrer"><?php echo esc_html($profile_details['github']); ?></a></dd></div><?php endif; ?>
|
<?php if (!empty($profile_details['github'])) : ?><div><dt>GitHub</dt><dd><a href="<?php echo esc_url($profile_details['github']); ?>" target="_blank" rel="noopener noreferrer"><?php echo esc_html($profile_details['github']); ?></a></dd></div><?php endif; ?>
|
||||||
<?php if (!empty($profile_details['qq'])) : ?><div><dt>QQ</dt><dd><?php echo esc_html($profile_details['qq']); ?></dd></div><?php endif; ?>
|
<?php if (!empty($profile_details['qq'])) : ?><div><dt>QQ</dt><dd><?php echo esc_html($profile_details['qq']); ?></dd></div><?php endif; ?>
|
||||||
<?php if (!empty($profile_details['wechat'])) : ?><div><dt><?php esc_html_e('微信', 'aksrt'); ?></dt><dd><?php echo esc_html($profile_details['wechat']); ?></dd></div><?php endif; ?>
|
<?php if (!empty($profile_details['wechat'])) : ?><div><dt><?php esc_html_e('微信', 'aksrt'); ?></dt><dd><?php echo esc_html($profile_details['wechat']); ?></dd></div><?php endif; ?>
|
||||||
|
<?php if ($registered_time !== '') : ?><div><dt><?php esc_html_e('注册时间', 'aksrt'); ?></dt><dd><?php echo esc_html($registered_time); ?></dd></div><?php endif; ?>
|
||||||
|
<?php if ($last_login_time !== '') : ?><div><dt><?php esc_html_e('最后登录', 'aksrt'); ?></dt><dd><?php echo esc_html($last_login_time); ?></dd></div><?php endif; ?>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in new issue
Block a user