2014-10-09 91 views
-2

我剛剛升級我的網站到一個新的版本WordPress的3.9.2。我注意到我的一個頁面並不像通常那樣工作。此頁面受密碼保護,我對其外觀進行了更改。當我升級時,它不再工作。在受密碼保護的網頁,我有這樣的代碼:WordPress的:密碼保護頁(2)

<?php 
echo "<script type='text/javascript'>\nwindow.location = 'http://www.google.com'</script>"; 
?> 

一個的目的是重定向到另一個頁面。他們與下面的這段代碼一起攜手。 這裏是我的舊代碼:

<?php 
function my_password_form() { 
    global $post; 
    $label = 'pwbox-'.(empty($post->ID) ? rand() : $post->ID); 
    $o = '<form action="' . get_option('siteurl') . '/wp-pass.php" method="post"> 
    ' . __("To view this protected post, enter the password below:") . ' 
    <label for="' . $label . '">' . __("Password:") . ' </label><input name="post_password" id="' . $label . '" type="password" size="20" maxlength="20" /><input type="submit" name="Submit" value="' . esc_attr__("Submit") . '" /> 
    </form> 
    '; 
    return $o; 
} 
add_filter('the_password_form', 'my_password_form'); 
?> 

升級之前,輸入重定向我到另一個頁面,這是我怎麼想它的工作密碼後。但請注意表單的動作屬性。在WP 3.9.2中,wp-pass.php不再存在,所以我正在尋找另一個代碼。我看到這行:

action="' . esc_url(site_url('wp-login.php?action=postpass', 'login_post')) . '" 

可是輸入密碼後,將其重定向我到WP登錄這不是我想要的東西。我需要幫助,這與我使用的舊代碼的工作方式相同。我不會降級我的WP或安裝任何插件。我只想將action=""的值更改。謝謝!

+0

有你只升級到3.9.2而不是4.0的原因? – rnevius 2014-10-09 08:09:44

+0

因爲我想使用3.9.2。即使我升級到4.0,仍然沒有wp-pass.php。 – 2014-10-09 08:12:35

+0

如果您查看[3.4版更新日誌](http://codex.wordpress.org/Version_3.4),您將看到以下內容:'通過wp-login.php中的操作設置發佈密碼cookie;退休wp-pass.php(少一個根文件);服從登錄密碼錶單提交的ssl首選項。希望這個對你有幫助。你現在需要鉤入** wp-login.php **。 – rnevius 2014-10-09 08:39:37

回答

0

我已經找到了答案。也許我的文件不兼容,這就是爲什麼它不起作用,但這裏是完整的代碼。

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

注:我使用WordPress 3.9.2

0

我有同樣的問題,我找到了解決辦法

1)設置你的網頁私人使用密碼

2)將此表單插入其他頁面(typique postpass wordpress表單):

<form action="https://exemple.com/wp-login.php?action=postpass" class="post-password-form" method="post" id="go-pro-espace"> 
    <input name="post_password" id="exemple" type="password" size="20" /><br /> 
    <input type="submit" value="submit"> 
</form> 

3)更改您的/wp-login.php文件(根目錄,在這個時候,這個位於行460):

from: 
wp_safe_redirect(wp_get_referer()); 
to: 
wp_safe_redirect("https://exemple.fr/your-protected-page"); 

看看答案:Wordpress protected page, POST form on a other page

+0

歡迎來到Stack Overflow!雖然這可能會在理論上回答這個問題,[這將是更可取的](// meta.stackoverflow.com/q/8259)在這裏包括答案的基本部分,並提供參考鏈接。 – 2017-07-05 11:28:34