wordpress ip_如何在WordPress中显示用户的IP地址
发布日期:2021-09-25 18:43:35 浏览次数:2 分类:技术文章

本文共 1618 字,大约阅读时间需要 5 分钟。

wordpress ip

Recently one of our users asked us if it was possible to detect and display individual visitors’ IP address in WordPress. Our answer was of course it is. In this article, we will show you how to display user’s IP address in WordPress.

最近,我们的一位用户问我们是否可以在WordPress中检测并显示单个访问者的IP地址。 我们的答案当然是。 在本文中,我们将向您展示如何在WordPress中显示用户的IP地址。

You can use this to create your own IP detection site. This way when a website visitor views your site, they can see their own IP address.

您可以使用它来创建自己的IP检测站点。 这样,当网站访问者查看您的网站时,他们可以看到自己的IP地址。

All you have to do is paste the following snippet in your theme’s functions.php file or in a .

您所要做的就是将以下代码段粘贴到主题的functions.php文件或于 。

// Display User IP in WordPressfunction get_the_user_ip() {if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {//check ip from share internet$ip = $_SERVER['HTTP_CLIENT_IP'];} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {//to check ip is pass from proxy$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];} else {$ip = $_SERVER['REMOTE_ADDR'];}return apply_filters( 'wpb_get_ip', $ip );}add_shortcode('show_ip', 'get_the_user_ip');

Next thing you need to do is add the following shortcode in your post, page, or in a sidebar .

接下来,您需要在帖子,页面或侧边栏添加以下短代码。

[show_ip]

[show_ip]

If you’re using the shortcode in your sidebar text widget, and it is not working, then you need to make sure that you .

如果您在侧边栏文本窗口小部件中使用了简码,但它不起作用,则需要确保 。

We hope this article helped you display user’s IP address in your WordPress site. If you have any questions or feedback, then please leave us a comment below.

我们希望本文能帮助您在WordPress网站中显示用户的IP地址。 如果您有任何疑问或反馈,请在下面给我们留言。

翻译自:

wordpress ip

转载地址:https://blog.csdn.net/cumyupx7788305/article/details/108613211 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:WordPress 3.2.1 – JSON,管理员,更简洁
下一篇:wordpress汉化技巧_55+最想要的WordPress技巧,窍门和技巧

发表评论

最新留言

第一次来,支持一个
[***.219.124.196]2024年04月16日 00时10分07秒