The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Add a "wrong password" message to protected posts? (4 posts)

  1. vonkanehoffen
    Posted 6 years ago #


    I'm trying to get wordpress to show a "wrong password" message when a user tries to access a protected post (front-end) and enters an incorrect password. Currently it just shows the exact same form again.

    I know the form can be customised with the 'the_password_form' filter, but can't see any variables passed back in the HTTP request that would allow me to conditionaly display some "wrong password" text from here.

    Anyone have any idea how to go about doing this?
    Bright ideas much appreciated!


  2. bjdr
    Posted 6 years ago #

    ttr738 did you manage to figure this out?
    Or maybe someone else have an idea?

  3. vonkanehoffen
    Posted 5 years ago #

    Nope. Still don't have a clue about it I'm afraid! You?

  4. antek
    Posted 5 years ago #

    Not the cleanest thing ever but here is a solution:

    if (!function_exists('theme_the_password_form')) {
    	function theme_the_password_form( $form) {
    		if (isset($_COOKIE['wp-postpass_' . COOKIEHASH]) && get_permalink() == wp_get_referer()) {
    			$form = '<p class="error">Invalid Password. Please try again.</p>' . $form;
    		return $form;
    add_filter( 'the_password_form', 'theme_the_password_form');

    hopefully that helps

Topic Closed

This topic has been closed to new replies.

About this Topic