{"id":124,"date":"2025-02-06T12:40:04","date_gmt":"2025-02-06T12:40:04","guid":{"rendered":"https:\/\/documentation.userswp.io\/article\/how-to-display-ip-address-of-users-during-registration\/"},"modified":"2025-03-26T15:39:37","modified_gmt":"2025-03-26T15:39:37","slug":"how-to-display-ip-address-of-users-during-registration","status":"publish","type":"gd_place","link":"https:\/\/userswp.io\/documentation\/article\/code-snippets\/how-to-display-ip-address-of-users-during-registration\/","title":{"rendered":"How to Display IP Address of Users During Registration?"},"content":{"rendered":"\n<p>At times, you might want to display the IP address of your users as and when they register on your website. This can be helpful in eliminating spam registrations.&nbsp;<\/p>\n\n\n\n<div class=\"wp-block-blockstrap-blockstrap-widget-alert d-flex align-items-center fade show alert alert-warning mb-3\" role=\"alert\"><span class=\"fas fa-exclamation-triangle me-2\"><\/span><span class=\"flex-grow-1\">By default, UsersWP does capture the IP address of all users, in its own meta table as <strong>user_ip <\/strong>&#8212; however, this information is not displayed or output anywhere.<\/span><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Code Snippet to Store IP Address of Users Upon Registration<\/h2>\n\n\n\n<p>You can use the following code snippet to capture and display user&#8217;s IP address when they register a new account:&nbsp;<\/p>\n\n\n\n<div class=\"wp-block-blockstrap-blockstrap-widget-alert d-flex align-items-center fade show alert alert-info mb-3\" role=\"alert\"><span class=\"fas fa-info-circle me-2\"><\/span><span class=\"flex-grow-1\">We recommend using the <a href=\"https:\/\/wpgeodirectory.com\/documentation\/article\/useful-plugins\/code-snippets-plugin\/\" target=\"_blank\">Code Snippets<\/a> plugin to add snippets to your site.<\/span><\/div>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-php\">function uwp_show_ip_column( $column ) {\n$column[&#039;user_ip&#039;] = __(&#039;IP Address&#039;, &#039;userswp&#039;);\n\treturn $column;\n}\nadd_filter( &#039;manage_users_columns&#039;, &#039;uwp_show_ip_column&#039; );\n\nfunction uwp_show_ip_column_value( $val, $column_name, $user_id ) {\n\tswitch ($column_name) {\n\t\tcase &#039;user_ip&#039; :\n\t\treturn uwp_get_usermeta($user_id, &#039;user_ip&#039;, &#039;N\/A&#039;);\n\t\tdefault:\n\t}\n\treturn $val;\n}\n\nadd_filter( &#039;manage_users_custom_column&#039;, &#039;uwp_show_ip_column_value&#039;, 10, 3 );<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>The above code will display the user&#8217;s IP address in the users&#8217; list on the backend.&nbsp;<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>At times, you might want to display the IP address of your users as and when they register on your website. This can be helpful in eliminating spam registrations.&nbsp; Code Snippet to Store IP Address of Users Upon Registration You can use the following code snippet to capture and display user&#8217;s IP address when they [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"article\/tags":[189,190],"article\/categories":[40,7],"class_list":["post-124","gd_place","type-gd_place","status-publish","hentry","gd_place_tags-user-registration","gd_place_tags-ip-address","gd_placecategory-code-snippets","gd_placecategory-tips-tricks-more"],"_links":{"self":[{"href":"https:\/\/userswp.io\/documentation\/wp-json\/wp\/v2\/article\/124","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/userswp.io\/documentation\/wp-json\/wp\/v2\/article"}],"about":[{"href":"https:\/\/userswp.io\/documentation\/wp-json\/wp\/v2\/types\/gd_place"}],"author":[{"embeddable":true,"href":"https:\/\/userswp.io\/documentation\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/userswp.io\/documentation\/wp-json\/wp\/v2\/comments?post=124"}],"version-history":[{"count":0,"href":"https:\/\/userswp.io\/documentation\/wp-json\/wp\/v2\/article\/124\/revisions"}],"wp:attachment":[{"href":"https:\/\/userswp.io\/documentation\/wp-json\/wp\/v2\/media?parent=124"}],"wp:term":[{"taxonomy":"gd_place_tags","embeddable":true,"href":"https:\/\/userswp.io\/documentation\/wp-json\/wp\/v2\/article\/tags?post=124"},{"taxonomy":"gd_placecategory","embeddable":true,"href":"https:\/\/userswp.io\/documentation\/wp-json\/wp\/v2\/article\/categories?post=124"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}