簡體   English   中英

受密碼保護的頁面的 WordPress“postpass”無法正確重定向

[英]WordPress "postpass" for password-protected page not redirecting properly

我繼承了這個網站(即,我沒有建立它)。 在 WordPress 常規設置中,我有:

WordPress Address: https://example.com/dev
Site Address: https://example.com

WordPress 目錄確實在一個名為“dev”的文件夾中,我可以通過 FTP 看到它。 然而,當我瀏覽面向公眾的網站時,我從未在 URL 中看到“dev”。 我以前從未見過以這種方式配置的 WordPress 主機。

無論如何,我們有幾個頁面使用通用的 WordPress“可見性:密碼保護”方法受密碼保護。 生成密碼輸入的頁面模板如下:

<form action="https://example.com/dev/wp-login.php?action=postpass" class="pass-form post-password-form" method="post">
    <p>This content is password protected. To view it please enter your password below:</p>
    <p><input type="password" class="pw-enter" name="post_password" id="pwbox-<?php the_ID(); ?>" size="20" /> <input type="submit" class="access-btn" name="Submit" value="Submit" /></p>
</form>

它在 Firefox 中沒有問題。 但是,在 Safari 和 Chrome 中,重定向永遠不會發生。 在您提交密碼后,頁面似乎只是重新加載或停留在那里,而沒有做任何事情。

我懷疑它與 WordPress 地址中的“dev”有關。

在表單中,如果我將操作更改為:

https://example.com/wp-login.php?action=postpass

...嘗試提交密碼時出現“找不到頁面”錯誤。 所以看起來瀏覽器正確地進入 wp-login.php,但沒有從那里重定向回原始頁面? 這是它需要去的地方,以便使用經過身份驗證的密碼重新加載該頁面。

如果我進入 WordPress 常規設置並從 URL 中刪除“dev”,則整個站點都會中斷。

關於我應該在哪里尋找這個問題的任何建議?

我遇到了同樣的問題,在舊帖子中找到了以下functions.php的代碼

function dcg_password_form_fix() {
global $post;
$label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );
$o = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" method="post">
' . __( "To view the contents of this page, enter the password below:" ) . '
<label for="' . $label . '">' . __( "Password:" ) . ' </label><input name="post_password" id="' . $label . '" type="password" size="20" maxlength="20" /><input type="hidden" name="_wp_http_referer" value="'.get_permalink().'" /><input type="submit" name="Submit" value="' . esc_attr__( "Submit" ) . '" />
</form>';
return $o;}add_filter( 'the_password_form', 'dcg_password_form_fix' );

秘密似乎是這條線

<input type="hidden" name="_wp_http_referer" value="'.get_permalink().'" />

在我的主題中,PopularFX 就像一個魅力

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM