首页 > 解决方案 > 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();
 }
}

标签: wordpresselementor

解决方案


推荐阅读