受 Wordpress 保护的页面,其他页面上的 POST 表单 [英] Wordpress protected page, POST form on a other page

查看:23
本文介绍了受 Wordpress 保护的页面,其他页面上的 POST 表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我,

我正在尝试向页面添加一个表单,通过 POST 方法将密码发送到 wp-login.php?action=postpass,然后将用户重定向到受保护的页面.

I'm trying to add a form to a page, that send password to the wp-login.php?action=postpass via POST method, and then redirect the user to the protected page.

问题是 action=postpass 似乎查看当前用于通过重定向表单发送密码的页面.

Problem is the action=postpass seems to look at the page currently used to send password via form for the redirection.

这个表格在主页上,任何人都可以填写,只需要输入密码.

This form is on homepage and can be completed by anyone, only password is asked.

有什么解决办法吗?

推荐答案

好吧,我做到了

这实际上不是解决这个问题的好方法,因为您需要覆盖一些 wordpress 文件(wp-login.php).

This is actually not a good solution to this problem, because you will need to override some wordpress files (wp-login.php).

1) 使用密码将您的页面设为私密

1) Set your page private with a password

2) 将此表单插入其他页面(典型的 postpass wordpress 表单):

2) Insert this form in an other page (typique postpass wordpress form) :

<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 行):

3) Change your /wp-login.php file (root directory, at this time, this is located line 460) :

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

这篇关于受 Wordpress 保护的页面,其他页面上的 POST 表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆