wordpress - WordPress wp 管理员未打开
问题描述
如果 Elementor 用户登录用户名和/或密码为空并提交,我使用此代码重定向。但是这段代码并没有让我打开 wp-login。有什么办法可以避免这种情况???
add_action( 'wp_authenticate', 'elementor_form_login_empty', 1, 2 );
function elementor_form_login_empty( $username, $pwd ) {
$referrer = $_SERVER['HTTP_REFERER']; // where did the post submission come from?
if ( empty( $username ) || empty( $pwd ) ) {
if ((!strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin') )) {
//redirect back to the referrer page, appending the login=failed parameter and removing any previous query strings
//maybe could be smarter here and parse/rebuild the query strings from the referrer if they are important
wp_redirect(preg_replace('/\?.*/', '', $referrer) . '/?login=failed' );
exit;
}
exit();
}
}
解决方案
推荐阅读
- c++ - 可以存储编号整数值的 C++ 容器(或函数)
- python - 如何将不同类型的数据写入二进制文件
- django - Django 模型 - 加入表而不添加模型
- angular - 在 ngFor 中测试 null
- c# - C#。重新抛出异常时的奇怪行为
- c# - 按下asp按钮时如何停止页面重新加载?
- prolog - Prolog 自然语言解析器,参数没有充分实例化
- c# - How to get the link from archetype single url picker in umbraco
- reporting-services - How to add Date and Time Parameter for two different days in SSRS
- javascript - 如何将所有 app.use 放在单独的公共文件中