字preSS生成用户登录WP_Error对象? [英] Wordpress to generate WP_Error Object for user login?

查看:210
本文介绍了字preSS生成用户登录WP_Error对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想即使正确返回登录错误信息用户键入他们的特权。换言之,以终止登录并显示错误信息。

I want to return the Login Error Message even user key-in their privileges correctly. In other words, to terminate the login and show the error message.

当我们键入错误的密码,文字preSS所示:

When we key-in wrong passwords, wordpress shows:

There was an error authenticating your details.

ERROR: The password you entered for the username admin is incorrect. Lost your password?

..在登录页面上。这是因为 WP_Error 返回的对象。

.. on the login page. This is because of WP_Error Object is returned.

所以,我好奇的问题是:

So my curious question is:


  • 如何获得/生成我自己的这个 WP_Error 对象,即可返回?它是阵列?

  • How to get/generate this WP_Error Object on my own, to return back? Is it Array?

推荐答案

您需要连接到身份验证字preSS挂钩。然后返回一个新的WP_Error对象生成错误消息并重定向回登录页面。下面是一个例子。

You need to hook into the authenticate wordpress hook. Then return a new WP_Error object to generate an error message and redirect back to the login page. Here is an example.

add_filter('authenticate', 'check_login_submit', 40, 3);

function check_login_submit($user, $username, $password) {
    $WP_Error = new WP_Error();
    $WP_Error->add('my_error', '<strong>Error</strong>: Something went wrong.');
    return $WP_Error;
}

这篇关于字preSS生成用户登录WP_Error对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆