WordPress’te bir kullanıcının IP adresini görüntülemek istiyor musunuz?
Kullanıcılarınızın ürünlerinizden birini yapılandırmak veya eğitiminizi tamamlamak için IP adreslerini bilmeleri gerekiyorsa, onlara kullanmaları gereken tam IP adresini göstermenize yardımcı olur.
Bu makalede, WordPress web sitenizde bir kullanıcının IP adresini nasıl görüntüleyeceğinizi göstereceğiz.
WordPress’te Kullanıcının IP Adresi Neden Görüntülenir?
IP (İnternet Protokolü) adresi, bir ağ üzerindeki donanım cihazlarını tanımlamak için kullanılan ve noktalarla ayrılmış bir sayı dizisidir. Bu, ziyaretçinin IP adresinin akıllı telefon, bilgisayar veya tablet gibi internete bağlanmak için kullandığı cihazı tanımladığı anlamına gelir.
Ziyaretçilerin IP adreslerini bilmelerinin gerekebileceği birçok durum vardır. Örneğin, bazen kullanıcıların bir yazılım parçasını, özellikle de güvenlik duvarları gibi WordPress güvenlik eklentilerini kurarken benzersiz IP adreslerini yazmaları gerekir.
Bu tür bir yazılım satıyorsanız, çevrimiçi belgelerinizde kullanıcının benzersiz IP adresini göstermeniz, müşterilerinizin yeni yazılımlarını kurmalarına yardımcı olacaktır.
Yazılımı kendiniz satmıyor olsanız bile, birçok WordPress blog yazarı üçüncü taraf yazılımların nasıl kullanılacağına dair faydalı kılavuzlar yayınlamaktadır. Okuyucunun IP adresini yazması gereken bir eğitim yazıyorsanız, kullanmaları gereken IP adresini tam olarak göstermek çok daha iyi bir eğitim oluşturmanıza yardımcı olabilir.
Bu yazıda, WordPress web sitenizde kullanıcının IP adresini göstermenin birkaç yolu var. Doğrudan belirli bir yönteme atlamayı tercih ederseniz, aşağıdaki bağlantıları kullanabilirsiniz.
- WordPress’te bir eklenti kullanarak ziyaretçinin IP adresi nasıl görüntülenir?
- WordPress’te kod kullanarak bir ziyaretçinin IP adresi nasıl görüntülenir?
1. WordPress’te Bir Eklenti Kullanarak Ziyaretçinin IP Adresi Nasıl Görüntülenir?
WordPress’te bir kullanıcının IP adresini görüntülemenin en kolay yolu Kullanıcı IP ve Konum eklentisini kullanmaktır. Bu, bir kısa kod kullanarak herhangi bir sayfada, yazıda veya widget’a hazır alanda ziyaretçinin IP adresini göstermenizi sağlayan basit bir eklentidir.
Öncelikle eklentiyi yüklemeniz ve etkinleştirmeniz gerekir. Yardıma ihtiyacınız varsa, lütfen bir WordPress eklentisinin nasıl kurulacağına ilişkin kılavuzumuza bakın.
Etkinleştirdikten sonra, ziyaretçinin IP adresini göstermek istediğiniz sayfayı, yazıyı veya widget’a hazır alanı açmanız yeterlidir. Ardından, ‘Artı’ blok ekle simgesine tıklayın ve ‘Kısa kod’u arayın.
Doğru blok göründüğünde, WordPress web sitenize eklemek için tıklayın.
Şimdi, [userip_location type=ip] kısa kodunu yazmanız yeterlidir. Kısa kodların kullanımına ilişkin daha ayrıntılı bilgi için WordPress’te kısa kod eklemeye ilişkin başlangıç kılavuzumuza bakın.
Bunu yaptıktan sonra, değişikliklerinizi kaydetmek için ‘Güncelle’ veya ‘Yayınla’ düğmesine tıklayın.
Şimdi bu sayfayı ziyaret ederseniz benzersiz IP adresinizi göreceksiniz.
2. WordPress’te Kod Kullanarak Kullanıcının IP Adresi Nasıl Görüntülenir?
WordPress blogunuza veya web sitenize bazı kodlar ekleyerek bir kullanıcının IP adresini de gösterebilirsiniz. Bu kod, sitenizin herhangi bir yerine yerleştirebileceğiniz benzersiz bir kısa kod oluşturacaktır.
Bu, sitenize bazı kodları kopyalayıp yapıştırmak kadar basittir. Ancak, web sitenizin kodunda değişiklik yapmadan önce bir yedek oluşturmak her zaman iyi bir fikirdir.
WordPress web sitenizi halihazırda yedeklemiyorsanız, en iyi WordPress yedekleme eklentileri uzman seçimimize bakabilirsiniz.
Kullanıcının IP adresini göstermek için temanızın functions.php dosyasını açın, siteye özel bir eklenti oluşturun veya bir kod parçacıkları eklentisi kullanın.
Hangi seçeneği seçerseniz seçin, aşağıdaki kodu yapıştırmanız yeterlidir:
function 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');
Bunu yaptıktan sonra, sitenize özel eklentinizi etkinleştirin, kod parçacığınızı kaydedin veya yaptığınız değişiklikleri sitenizin functions.php dosyasına kaydedin.
Artık herhangi bir sayfada, gönderide veya widget’a hazır alanda ziyaretçinin IP adresini göstermek için kullanabileceğiniz bir [show_ip] kısa kodu oluşturdunuz.
Kısa kodun nasıl yerleştirileceğine ilişkin adım adım kılavuz için WordPress’te kısa kod eklemeye ilişkin başlangıç kılavuzumuza bakın.
Bu makalenin WordPress sitenizde bir kullanıcının IP adresini nasıl görüntüleyeceğinizi öğrenmenize yardımcı olduğunu umuyoruz. WordPress sitenizde kullanıcı kaydına nasıl izin vereceğinize ve küçük işletmeler için en iyi canlı sohbet yazılımına ilişkin kılavuzumuza da göz atmak isteyebilirsiniz.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.
Syed Balkhi says
Hey WPBeginner readers,
Did you know you can win exciting prizes by commenting on WPBeginner?
Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
You can get more details about the contest from here.
Start sharing your thoughts below to stand a chance to win!
Christopher says
Great article! Is it also possible to show visitors country?
WPBeginner Support says
That would require some advanced php or a plugin, we don’t have a recommended method at the moment.
Yönetici
Lathif says
unfortunately there is still a weakness of the function, that is the problem of “cache”.
visitors will see the same ip address (even if the router is restarted) when they are not clearing “cache” in the browser.
Pamela says
Is there a way to display the user’s country flag with this code?
Thanks.
Lloyd says
How about a city or state instead of IP?
Beatriz says
Where can I see the IP’s collected? and should I paste the snippet of the code on the top of my function.php code?
WPBeginner Support says
Paste the code at the bottom of your functions.php file. You will have to use shortcode
[show_ip]
inside a text widget. See our guide on how to add and use widgets in WordPress.Yönetici
Brigitte Scherieble says
hey,
I am from Germany and I am not a computer freak. But I have the job to find out of the client IP (out of Google Analytics) the Company of the visiter. Can you help me?
Evan says
This works great, thank you! Is there any way to have it also display the hostname, perhaps with a separate shortcode?
Reuben Tinto says
Hi,
Is it possible to obtain the IP of a previous blog visitor trough this method? If not are you aware of any other courses of action I can take?
Also will I be able to access code if I do not have a premium wordpress account?
I have been trying to locate the IP of an anonymous twitter troll and would really appreciate some help!
Reuben
Mike says
Thanks for the tutorial. Please excuse if this is a dumb question but I’m new to working with WordPress.
If I want to store the visitors IP address along with the date and time they visited a post, should I create a separate mysql database table or is there an existing wp table that collects this information that I can retrieve?
WPBeginner Support says
WordPress only stores vistor’s information in the database if they decide to leave a comment. You can create a separate database to collect this information if you want.
Yönetici
Mohammad Mursaleen says
Creating a table for such functionality in WordPress is not an efficient move. I would prefer to do this using custom post type.
I have answered a similar question over here;
Vivek Digarse says
Thanks !
John says
Thanks for this, works fine.
But is it possible to use this to monitor new user subscriptions?
alexander kochubey says
Thanks for reply, I’ll modify some plugin for some system, I’ll describe it later
meera says
HI
Thank you so much…. it works fine……..
Abhisek Padhi says
@pippin you are correct. Your code worked fine, but wpbeginner’s code was also working fine.
Doug Hall says
Display it where? I don’t understand the post at all.
as says
Everywhere use shortcode [show_ip]
Pippin Williamson says
It should probably be noted that $_SERVER[‘REMOTE_ADDR’] will not always retrieve the IP properly.
If the user is on a shared connection, you will need to use $_SERVER[‘HTTP_X_FORWARDED_FOR’].
If the user is behind a proxy, you will need to use $_SERVER[‘HTTP_X_FORWARDED_FOR’].
The IP can also be present in $_SERVER[‘HTTP_CLIENT_IP’].
To properly get the IP reliably, something like this should be used:
function 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( ‘edd_get_ip’, $ip );
}
Pippin Williamson says
Formatted version: https://gist.github.com/pippinsplugins/9641841
WPBeginner Support says
Thanks Pippin, we have updated the article.
Yönetici
Chris Black says
Always worth noting that although you can read the IP address with PHP that it may not be useful because people have shared IP addresses, dynamic IP, access websites from different networks/locations and because it is possible to fake the IP address that PHP sees. So – only use an IP address with caution.