Change the default registry error – WordPress Development Stack Exchange

I'm trying to change the standard WordPress errors that appear when I register.

I'm trying to remove the original WordPress feature and create a new one that uses this code, but no effect. Any idea what I'm doing wrong?

                / * Change default WordPress registry error * /
remove_filter (& # 39; registration_errors & # 39 ;, & 39; registration_errors & # 39;);
add_filter (& # 39; registration_errors & # 39 ;, & # 39; registration_errors_so_16002591 & # 39;);

Function registration_errors_so_16002591 ($ errors)
{
if (isset ($ error-> error)['email_exists'] )) {
$ error-> error['email_exists'][0]    = & # 39; email alreadytook& # 39 ;;
}
if (isset ($ error-> error)['username_exists'] )) {
$ error-> error['username_exists'][0]    = & # 39; Nick peck& # 39 ;;
}
// other errors
// ['empty_email']
    // ['empty_username']

    Return $ error;
}