Home » Web Design » How To Display User And Visitor IP Addresses On WordPress Using Shortcodes

How To Display User And Visitor IP Addresses On WordPress Using Shortcodes

Creating a shortcode to display WordPress visitor’s IP addresses

WordPressThere are many benefits when displaying user/visitor IP addresses inside your WordPress pages and posts, for one it’s a great crime deterrent, just like those security alarm signs outside offices and homes. If a malicious visitor decides to visit your WordPress website without an IP disguise, they will most likely see their IP has been identified and will ignore the WordPress website in question to avoid hairy situations. Displaying IP addresses on your website is also a great way to inform your visitors of their transmission control protocol, better known as internet protocol (IP) if they need to use this specific information.

  • We have created a WordPress functions snippet which will allow you to display user and visitor IP addresses utilizing the shortcode [ user_ip].

Down Copy and paste the snippet below into your theme’s functions.php file

function display_user_ip() {
        $ip = $_SERVER['REMOTE_ADDR'];
        return $ip;
add_shortcode('user_ip', 'display_user_ip');

Use shortcode: [ user_ip] in pages and post or include the use of shortcodes in template files and widgets.

To properly use the shortcode remove the space before the first letter.
BBPress Shortcode Example

Jared Harrison

Jared Harrison is an accomplished tech author and entrepreneur, bringing forth over 20 years of extensive expertise in cybersecurity, privacy, malware, Google Analytics, online marketing, and various other tech domains. He has made significant contributions to the industry and has been featured in multiple esteemed publications. Jared is widely recognized for his keen intellect and innovative insights, earning him a reputation as a respected figure in the tech community.

More Reading

Post navigation

1 Comment

  • Great thanks for this tip! I found it with my first search on google! You saved me a lot of time that I would’ve spent researching.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

How to build a professional WordPress website from scratch

How to Find WordPress Page and Post IDs

How to remove Infinite Scroll credits on Jetpack