WordPress.org

Support

Support » How-To and Troubleshooting » WP inserting BRs & Ps in ‘Password Protected’ form

WP inserting BRs & Ps in ‘Password Protected’ form

  • Hi guys,

    Really annoying problem here: I’ve edited the text that gets displayed above the “Password protected entry” form and I’ve also re-jigged the HTML form to fit within my site structure and CSS, but WordPress is insistent on placing <BR> and </P> tags throughout the form, and it’s driving me nuts. Here’s my code:

    function get_the_password_form() {
    	$output = "<p>Think you're part of the Mob eh. What's the codeword wiseguy?</p>" .
    	'<form action="' . get_option('siteurl') . '/wp-pass.php" method="post" class="standardform"><fieldset><label for="post_password">Password </label><input id="post_password" name="post_password" type="password" /><label for="Send"></label><input id="Send" type="submit" name="Submit" value="Go" /></fieldset></form>';
    	return $output;
    }

    This is what it’s outputting:

    <p>Think you’re part of the Mob eh. What’s the codeword wiseguy?</p>
    <form action="http://phobea.com/wp-pass.php" method="post" class="standardform"><fieldset><label for="post_password">Password </label>
    <input id="post_password" name="post_password" type="password" /><label for="Send"></label>
    <input id="Send" type="submit" name="Submit" value="Go" /></fieldset></form>

    As you can see it’s putting <BR> tags after the label, not something I want it to do at all as it messes up my formatting. It’s not technically very good HTML either.

    As you can see I’ve tried stripping all whitespace from the form (with the proper whitespace, WP adds even more peculiar <BR> and <P> tags throughout. I also searched the functions files for any relevant sr_replace calls but I can’t find any.

    Has anybody any idea why this is happening or is it a bug?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Sorry to bump but I really need this fixed ASAP and can’t figure it out for the life of me.

    Someone must know why this is happening, surely?

    This is how I fixed the annoying line breaks on password-protected posts:

    function get_the_password_form() {
    $output = '<form action="' . get_option('siteurl') . '/wp-pass.php" method="post">
    <p>' . __("This post is password protected. To view it please enter your password below:") . '</p>
    <p><input name="post_password" type="password" size="20" /><input type="submit" name="Submit" value="' . __("Submit") . '" /></p>
    </form>
    ';
    return $output;
    }

    Thank you! I’ll give that a go.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘WP inserting BRs & Ps in ‘Password Protected’ form’ is closed to new replies.
Skip to toolbar