[wp-hackers] Users with no email address

Peter van der Does peter at avirtualhome.com
Tue Jan 10 00:04:36 UTC 2012


On Mon, 9 Jan 2012 21:36:46 +1100
Lox <lox.dev at knc.nc> wrote:

> Hello,
> 
> For an app, I need admins to add users that may not have an email
> address. How would you handle that case? I would like to avoid a
> seperate table.
> 
> Regards
> 
You can add the following in your theme functions.php

add_filter('user_profile_update_errors','allow_no_email',10,3);
function allow_no_email($errors, $update, $users) {
	if (isset($errors->errors['invalid_email']) &&
$users->user_email='a') { unset ($errors->errors);
		$users->user_email='';
	}
}

Above code is also available here: http://pastebin.com/P44V9Edf

The admins need to use "a" for the email, WordPress has it hard coded
that the field is required. yes you could bypass this with a jQuery
script as well :) If you would like that let me know,

You can change "a" to anything, as long as it is a invalid email
address.

I'm not sure what the consequences are of having no email address, the
above just allows you to add a user with no email address.


-- 
Peter van der Does

GPG key: CB317D6E

IRC: Ganseki on irc.freenode.net
Twitter: @petervanderdoes

WordPress Plugin Developer
Blog: http://blog.avirtualhome.com
Forums: http://forums.avirtualhome.com
Twitter: @avhsoftware


More information about the wp-hackers mailing list