WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Plugin API/Filter Reference/user registration email

Description

This filter hooks into the very start of the register_new_user() function of wp-login.php after the user has been sanitised, and is used to manipulate the value submitted for user_email.

As it is the very first filter to be called in the registration process it's a reasonable (i.e. not really good but possible) place to manipulate user registration data in $_POST as well as the email field itself before that data is further processed.

This means that it can be used for instance to set the email address field to be the same as the username (which on your registration form you could label as email address if you wanted to), and do other more interesting form customisations.

Example

function use_email_as_username($user_email)
{
	return $_POST['user_login'];
}

add_filter('user_registration_email', 'use_email_as_username');

Return to Plugin API/Filter Reference