如何编辑Wordpress注册页错误代码?

如何编辑Wordpress注册页错误代码?,wordpress,login,Wordpress,Login,我试图找到一种方法来编辑wordpress注册页面抛出的错误代码。例如: 错误:请输入用户名 错误:电子邮件地址不正确 这些存储在哪里,以便我可以更改它们 非常感谢。在wp login.php中有一个过滤器。但是不要触摸WordPress核心文件,过滤器和动作挂钩已经就位,这样你就可以在不编辑核心的情况下修改WP行为 add_filter( 'registration_errors', 'registration_errors_so_16002591' ); function registra

我试图找到一种方法来编辑wordpress注册页面抛出的错误代码。例如:

错误:请输入用户名

错误:电子邮件地址不正确

这些存储在哪里,以便我可以更改它们


非常感谢。

wp login.php
中有一个过滤器。但是不要触摸WordPress核心文件,过滤器和动作挂钩已经就位,这样你就可以在不编辑核心的情况下修改WP行为

add_filter( 'registration_errors', 'registration_errors_so_16002591' );

function registration_errors_so_16002591( $errors )
{
    if( isset( $errors->errors['invalid_email'] ) ) {
        $errors->errors['invalid_email'][0] = '<strong>bad</strong> email';
    }
    if( isset( $errors->errors['username_exists'] ) ) {
        $errors->errors['username_exists'][0] = 'nick <strong>picken</strong>';
    }
    // Other errors
    // ['empty_email']
    // ['empty_username']

    return $errors;
}
add_filter('registration_errors'、'registration_errors_so_16002591');
函数注册错误16002591($errors)
{
如果(设置($errors->errors['invalid_email'])){
$errors->errors['invalid_email'][0]='bademail';
}
if(设置($errors->errors['username\u exists'])){
$errors->errors['username\u exists'][0]=“nickpicken”;
}
//其他错误
//[“空邮件”]
//['empty_username']
返回$errors;
}

相关问答:

wp login.php
中有一个过滤器。但是不要触摸WordPress核心文件,过滤器和动作挂钩已经就位,这样你就可以在不编辑核心的情况下修改WP行为

add_filter( 'registration_errors', 'registration_errors_so_16002591' );

function registration_errors_so_16002591( $errors )
{
    if( isset( $errors->errors['invalid_email'] ) ) {
        $errors->errors['invalid_email'][0] = '<strong>bad</strong> email';
    }
    if( isset( $errors->errors['username_exists'] ) ) {
        $errors->errors['username_exists'][0] = 'nick <strong>picken</strong>';
    }
    // Other errors
    // ['empty_email']
    // ['empty_username']

    return $errors;
}
add_filter('registration_errors'、'registration_errors_so_16002591');
函数注册错误16002591($errors)
{
如果(设置($errors->errors['invalid_email'])){
$errors->errors['invalid_email'][0]='bademail';
}
if(设置($errors->errors['username\u exists'])){
$errors->errors['username\u exists'][0]=“nickpicken”;
}
//其他错误
//[“空邮件”]
//['empty_username']
返回$errors;
}
相关问答: