How to Display IP Address of Users During Registration?

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. 

By default, UsersWP does capture the IP address of all users, in its own meta table as user_ip -- however, this information is not displayed or output anywhere. 

Code Snippet to Store IP Address of Users Upon Registration

You can use the following code snippet to capture and display user's IP address when they register a new account: 

We recommend using the Code Snippets plugin.

function uwp_show_ip_column( $column ) {
$column['user_ip'] = __('IP Address', 'userswp');
	return $column;
}
add_filter( 'manage_users_columns', 'uwp_show_ip_column' );

function uwp_show_ip_column_value( $val, $column_name, $user_id ) {
	switch ($column_name) {
		case 'user_ip' :
		return uwp_get_usermeta($user_id, 'user_ip', 'N/A');
		default:
	}
	return $val;
}

add_filter( 'manage_users_custom_column', 'uwp_show_ip_column_value', 10, 3 );

The above code will display the user's IP address in the users' list on the backend. 

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.