簡體   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