WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. vonkanehoffen
    Member
    Posted 3 years ago #

    Hi!

    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!

    Cheers

  2. bjdr
    Member
    Posted 3 years ago #

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

  3. vonkanehoffen
    Member
    Posted 3 years ago #

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

  4. antek
    Member
    Posted 2 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