How To Validate A Password Protected Page

Question

For reason unbeknownst to me (I’m not the original developer). This custom WordPress site doesn’t show the password protected login form…”This content is password protected! To view it please enter your password below:”.

The page shows it’s protected, but visitors can still see the full page. I manage to use the code that works that triggers the form and block access. Login works fine and wrong password doesn’t allow access to the page. This is fine. It just doesn’t show an error message.

Do anyone know how to display an error message or even a class so I can input a error message when the wrong password is submitted.

<?php if ( post_password_required() ) { ?>
<form method="post" action="/wp-login.php?action=postpass">
    <p>This content is password protected. To view it please enter your password below:</p>
    <input type="password" style="margin:10px 0;" size="20" id="pwbox-<?php the_ID(); ?>" name="post_password"/></label><br/>
    <input type="submit" value="Submit" name="Submit"/></p>
</form>
<?php } else { ?>
    // echo out all of the post content
<?php } ?>
0
, user3773297 3 years 2020-04-07T16:51:08-05:00 0 Answers 93 views 0

Leave an answer

Browse
Browse