WP Password Cookie Protection
-
what i want to do is have a permanent “password” field in my sidebar nav in my theme that will allow users to enter a password to view a password protected page.
to do this I have created a page and set it to password protected in the wordpress admin and created a password.
then ive edited my themes sidebar to include
<form action="http://mysite.com/wp-mine-pass.php" method="post"> <input name="post_password" id="pwbox-105" type="password" size="20" /> <input class="submit_button" type="submit" name="Login" value="Login" /> </form>now because the standard redirect in the wp-pass.php file is the wp_get_referer and the refer in this case could be any page (as the password box is part of the sidebar) i have duplicated this and hardcoded the redirect to the page i want as follows in the file “wp-mine-pass.php”
<?php /** * Creates the password cookie and redirects back to where the * visitor was before. * * @package WordPress */ /** Make sure that the WordPress bootstrap has run before continuing. */ require( dirname(__FILE__) . '/wp-load.php'); if ( get_magic_quotes_gpc() ) $_POST['post_password'] = stripslashes($_POST['post_password']); // 10 days setcookie('wp-postpass_' . COOKIEHASH, $_POST['post_password'], time() + 864000, COOKIEPATH); wp_safe_redirect('specialists'); ?>however rather than showing the specialists page unprotected it just shows the standard password protected page and login box in the centre of the content which means i have to re-enter the password again to view the content
anyone any ideas?
However what happends is that when the password
The topic ‘WP Password Cookie Protection’ is closed to new replies.