duanhe3393 2014-06-23 07:46
浏览 45
已采纳

WordPress:密码保护页面

I need help with regards to WordPress Password Protect page/s.

After inputting a password, you are usually redirected to the same page where you entered or just showing you the content after inputting password.

What I want is that, after I input the correct password, it redirects to another page of my site. How is that possible? As much as possible, I won't be using any plugins.

Below is my code for functions.php:

<?php
function my_password_form() {
    global $post;
    $label = 'pwbox-'.(empty($post->ID) ? rand() : $post->ID);
    $output = '<form action="' . get_option('siteurl') . '/wp-pass.php" method="post">
    <p><strong>'.__("Cakes").'</strong></p>
    <p>' . __("This page is password-protected. Please input password below.") . '</p>
    <center><label for="' . $label . '">' . __("Password:") . '<input name="post_password" id="' . $label . '" type="password" size="40"  style="height:20px;"/></label><input type="image" src="images/btn_member02.png" name="Submit" value="' . esc_attr__("Submit") . '"/></center>
    </form>
    ';
    return $output;
}
add_filter('the_password_form', 'my_password_form');
?>

As an example, when I input the correct password on page www.mysite.com/memberlogin, I should be redirected to www.mysite.com/memberpage.

  • 写回答

3条回答 默认 最新

  • douwen5741 2014-10-09 08:35
    关注

    I found a thread and forgot to copy the link but here is the code:

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

    I placed that code in my password protected page. After inputting the password, it redirects me to another page - which what I wanted it to do.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?