Support » Plugins » Hacks » Writing a Plugin to amend the core – possible ?

Viewing 8 replies - 1 through 8 (of 8 total)
  • The function has a filter which tells you where it failed you could use to catch the exit and run your own validation and return true instead of false.

    	// Test for invalid characters
    	if ( !preg_match( '/^[a-zA-Z0-9!#$%&\'*+\/=?^_{|}~\.-]+$/', $local ) ) {
    		return apply_filters( 'is_email', false, $email, 'local_invalid_chars' );


    add_filter( 'is_email', 'my_email_validation', 10, 3 );
    function my_email_validation( $return, $email, $context ) {
        if( 'local_invalid_chars' != $context ) {
            return $return;
        } else {
            // Validate $email however you please, return false or true

    If you think this should be part of core, head over to Trac and open a ticket.

    Hope that helps.

    Also note, that if you do this you will skip the domain validation parts of the is_email function and will need to include that validation in your function.

    Hi Jackson, thanks for the response.

    Im hammering away at the code now.. will post-up what I have and look forward to comments.


    Am I correct i thinking that I will need to run all of the validation that follows the local part in the ‘is_email’ function ?

    That’s correct.

    Check this out:

    Might do just what you want.

    Hmmm.. Ive tested it, and no-dice.. still errors – sadly.

    But it cant be far away from what I need..

    *keeps going*

    Ran up against this same problem a while ago, and this was the solution I came up with. Put the following code into your functions.php file. Pulling the email address from the post variable was the only way that would work.

    function email_validator($email_address='' ){
            //Validator will fail on apostrophes when is_email is called if we don't check the POST var instead of $email_address
            $user_email_address = ($_POST['email']) ? $_POST['email'] : $email_address;
            if(filter_var(stripslashes($user_email_address), FILTER_VALIDATE_EMAIL)){
                return stripslashes($user_email_address);
            } else {
                return false;
    add_filter('is_email', 'email_validator', 1, 1);
    add_filter( 'sanitize_email', 'email_validator', 1, 1 );

    Works a treat.

    Good stuff..thanks !

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Writing a Plugin to amend the core – possible ?’ is closed to new replies.