Discussion:
Apostrophes and is_email() alternative
Tom Barrett
2013-10-03 11:17:40 UTC
Permalink
I'm looking at an 'apostrophe in email' issue. The codex page for
is_email() says it is deprecated (but not what to use instead). Other
functions in core appear to use the function (eg: sanitize_option()).

Trying to add a user to a vanilla 3.6.1 install with an apostrophe in the
email fails.

What is the accepted method to check email validity (for use as WordPress
user accounts)?

Is there a good reason not to use FILTER_VALIDATE_EMAIL ?

Thanks.
--
http://www.tcbarrett.com | http://gplus.to/tcbarrett |
http://twitter.com/tcbarrett
Thomas Scholz
2013-10-03 11:24:23 UTC
Permalink
Post by Tom Barrett
What is the accepted method to check email validity (for use as WordPress
user accounts)?
Is there a good reason not to use FILTER_VALIDATE_EMAIL ?
No, there is no good reason. You can extend the internal checker with
filter_var().

See this plugin for an example:
https://gist.github.com/toscho/972837

Thomas
J.D. Grimes
2013-10-03 12:47:34 UTC
Permalink
Post by Tom Barrett
The codex page for
is_email() says it is deprecated (but not what to use instead). Other
functions in core appear to use the function (eg: sanitize_option()).
Right, it really isn't deprecated, just the second argument. I've updated the codex page to make this clear.
Tom Barrett
2013-10-03 14:42:05 UTC
Permalink
Thanks JD! Much clearer.

Thanks Thomas, the gist needs a little tweaking as it doesn't work in it's
current state.

The next step in this lovely journey is that the $email var passed around
in the hooks has the apostrophe escaped. And back slashes are not valid.

This is fun :)

// Sent by Nexus
Post by J.D. Grimes
Post by Tom Barrett
The codex page for
is_email() says it is deprecated (but not what to use instead). Other
functions in core appear to use the function (eg: sanitize_option()).
Right, it really isn't deprecated, just the second argument. I've updated
the codex page to make this clear.
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Ian Dunn
2013-10-03 17:26:10 UTC
Permalink
FYI, there are some Core tickets around this (and related) issues:

http://core.trac.wordpress.org/ticket/16867
http://core.trac.wordpress.org/ticket/18658
http://core.trac.wordpress.org/ticket/18039
Post by Tom Barrett
Thanks JD! Much clearer.
Thanks Thomas, the gist needs a little tweaking as it doesn't work in it's
current state.
The next step in this lovely journey is that the $email var passed around
in the hooks has the apostrophe escaped. And back slashes are not valid.
This is fun :)
// Sent by Nexus
Post by J.D. Grimes
Post by Tom Barrett
The codex page for
is_email() says it is deprecated (but not what to use instead). Other
functions in core appear to use the function (eg: sanitize_option()).
Right, it really isn't deprecated, just the second argument. I've updated
the codex page to make this clear.
Loading...