当有人尝试在我的网站上登录时,如果出现错误,我想更改显示的文字。我发现当前显示的消息在哪里,我想改变。它们位于user.php文件(with open(IN_PATH, 'rt', encoding=ENCODING, newline='') as in_file, \
open(OUT_PATH, 'wt', encoding=ENCODING, newline='') as out_file:
reader = csv.DictReader(in_file)
writer = csv.DictWriter(out_file, reader.fieldnames)
writer.writeheader()
for row in reader:
row['Mail'] = create_signature(row['Mail'], secret_bytes)
writer.writerow(row)
)上。
具体做法是:
>>> import sys, csv, io
>>> demo_input = io.StringIO('''\
... Mail
... DHSKA@gmail.com
... DJÖANw12@gmail.com
... JSNÖS83@ymail.com
... HDKDLSA@gmail.com
... KKKDLAmS19@yamil.com
... ''')
>>> demo_output = io.StringIO()
>>> with demo_input as in_file:
... reader = csv.DictReader(in_file)
... writer = csv.DictWriter(demo_output, reader.fieldnames)
... writer.writeheader()
... for row in reader:
... row['Mail'] = create_signature(row['Mail'], secret_bytes)
... writer.writerow(row)
...
46
46
46
46
46
>>> print(demo_output.getvalue())
Mail
3KaSw4QeA5l0rz49uutaDGemn4Et4CQnbnngm6mmpjE=
dP9IU66yKnYP/6mFRZ6TAAAN3lmxAcUPk9o1iFfpGDs=
ajNdCZF8ndw2SrgtSzcVCbeSpFsXI/Z6Ep0IC2fj+WU=
TgeFEj8CgvcQbVcLHTIIY1ULLnYkWAZaia5k01IQiJY=
Xu94abwV/5/HUXY+T3NpUgulGvew+L0UYzkPuRSv/98=
和
wp-includes/user.php
我想我应该在我的function wp_authenticate_email_password( $user, $email, $password ) {
if ( $user instanceof WP_User ) {
return $user;
}
if ( empty( $email ) || empty( $password ) ) {
if ( is_wp_error( $user ) ) {
return $user;
}
$error = new WP_Error();
if ( empty( $email ) ) {
$error->add( 'empty_username', __( '<strong>ERROR</strong>: The email field is empty.' ) ); // Uses 'empty_username' for back-compat with wp_signon()
}
if ( empty( $password ) ) {
$error->add( 'empty_password', __( '<strong>ERROR</strong>: The password field is empty.' ) );
}
return $error;
}
if ( ! is_email( $email ) ) {
return $user;
}
$user = get_user_by( 'email', $email );
if ( ! $user ) {
return new WP_Error( 'invalid_email',
__( '<strong>ERROR</strong>: Invalid email address.' ) .
' <a href="' . wp_lostpassword_url() . '">' .
__( 'Lost your password?' ) .
'</a>'
);
}
文件中使用if ( is_wp_error( $user ) ) {
return $user;
}
if ( ! wp_check_password( $password, $user->user_pass, $user->ID ) ) {
return new WP_Error( 'incorrect_password',
sprintf(
/* translators: %s: email address */
__( '<strong>ERROR</strong>: The password you entered for the email address %s is incorrect.' ),
'<strong>' . $email . '</strong>'
) .
' <a href="' . wp_lostpassword_url() . '">' .
__( 'Lost your password?' ) .
'</a>'
);
}
return $user;
}
我的孩子主题,但我不熟悉它。任何人都可以帮助我吗?
答案 0 :(得分:0)
Wordpress已经提供了更改错误文本的选项,您可以使用functions.php
来完成请点击此链接https://codex.wordpress.org/Plugin_API/Filter_Reference/login_errors
答案 1 :(得分:0)
Function.php是覆盖错误消息的方法。
你可以使用login_errors过滤器钩子来做到这一点,方法如下:
的add_filter( 'login_errors', 'login_error_message');
function login_error_message($error){
//check if that's the error you are looking for
$pos = strpos($error, 'incorrect');
if (is_int($pos)) {
//its the right error so you can overwrite it
$error = "Wrong information";
}
return $error;
}