在wordpress中添加一个函数,如果登录失败,则返回true


Adding a function in wordpress which returns true if the login has failed

我有点不擅长wordpress,因为我不想(我也不想)学习那么多,但我的工作之一要求我在其中编写一些模块,所以这就是我来这里寻求帮助的原因。

我想要一个可以从这样的站点调用的函数。

<?php if (wp_login_failed()): ?>
    <h1>Bad username or password!</h1>
<?php endif ?>

对这些钩子和操作一无所知,我只需要一个函数,我可以调用它来检查登录是否失败。

提前感谢!

您要查找的是is_user_logged_in()函数,如果当前用户存在并已登录,它将返回 true。

了解wordpress的最佳方法是从谷歌搜索和检查文档开始:https://developer.wordpress.org/reference/functions/is_user_logged_in/

希望对你有帮助