User IP In Registration Email?

Advert test


Staff member
Is there any way to get the user's IP added to the registration notification email?

It would make culling spammers a lot easier!

It's this email:
Subject: [Site Name] New User Registration
X-PHP-Originating-Script: 1027:class-phpmailer.php
Date: Tue, 24 Apr 2012 10:36:57 +0000
From: WordPress <>
Message-ID: <>
X-Priority: 3
X-Mailer: PHPMailer 5.1 (
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="UTF-8"

New user registration on your site Site Name:

Username: username

E-mail: email@domain

Haven't tested this but try it and see how you get on with a test site:

Add the following to /wp-content/themes/[YOUR THEME NAME]/functions.php

if ( !function_exists('wp_new_user_notification') ) :
 * Notify the blog admin of a new user, normally via email.
 * @since 2.0
 * @param int $user_id User ID
 * @param string $plaintext_pass Optional. The user's plaintext password
function wp_new_user_notification($user_id, $plaintext_pass = '') {
    $user = new WP_User($user_id);

    $user_login = stripslashes($user->user_login);
    $user_email = stripslashes($user->user_email);

    // The blogname option is escaped with esc_html on the way into the database in sanitize_option
    // we want to reverse this for the plain text arena of emails.
    $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);

    $message  = sprintf(__('New user registration on your site %s:'), $blogname) . "\r\n\r\n";
    $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
    $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";
    $message .= sprintf(__('IP Address: %s'), $_SERVER['REMOTE_ADDR']) . "\r\n";

    @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message);

    if ( empty($plaintext_pass) )

    $message  = sprintf(__('Username: %s'), $user_login) . "\r\n";
    $message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n";
    $message .= sprintf(__('IP Address: %s'), $_SERVER['REMOTE_ADDR']) . "\r\n";
    $message .= wp_login_url() . "\r\n";

    wp_mail($user_email, sprintf(__('[%s] Your username and password'), $blogname), $message);