简体   繁体   中英

Wordpress protected page, POST form on a other page

I,

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.

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.

Is there a solution to do it ?

Ok guys, i did make it

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

1) Set your page private with a password

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) 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" );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM