繁体   English   中英

WordPress的登录失败重定向URL无法正常工作

[英]wordpress login failed redirect url does not work properly

在我的wordpress项目中,我为用户创建了一个前端登录,当用户输入错误的登录信息时,它必须使用url重定向登录失败的附件。 下面的代码是第一次执行此操作,然后在尝试登录时将其连续追加到URL。如何限制此值。

add_action('wp_login_failed', 'my_front_end_login_fail'); 

    function my_front_end_login_fail($username){
        // Get the reffering page, where did the post submission come from?
        $referrer = $_SERVER['HTTP_REFERER'];

        // if there's a valid referrer, and it's not the default log-in screen
        if(!empty($referrer) && !strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin')){
            // let's append some information (login=failed) to the URL for the theme to use


              wp_redirect($referrer . '&login=failed'); 

        exit;
        }

    }

任何帮助将不胜感激。

试试这个代码

add_action('wp_login_failed', 'my_front_end_login_fail'); 

    function my_front_end_login_fail($username){
        // Get the reffering page, where did the post submission come from?
        $referrer = $_SERVER['HTTP_REFERER'];



        // if there's a valid referrer, and it's not the default log-in screen
        if(!empty($referrer) && !strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin')){
            // let's append some information (login=failed) to the URL for the theme to use

              ////already not login failed append
              if(!strstr($referrer,'&login=failed'))
               {
                 wp_redirect($referrer . '&login=failed'); 
               }
              else
               {
               ////if alreday append go to same url
                 wp_redirect($referrer); 
               }

        exit;
        }

    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM