WordPress.org

Forums

WP inserting BRs & Ps in 'Password Protected' form (5 posts)

  1. SpencerLavery
    Member
    Posted 8 years ago #

    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?

  2. SpencerLavery
    Member
    Posted 8 years ago #

    Sorry to bump but I really need this fixed ASAP and can't figure it out for the life of me.

  3. SpencerLavery
    Member
    Posted 8 years ago #

    Someone must know why this is happening, surely?

  4. marsie
    Member
    Posted 7 years ago #

    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;
    }

  5. SpencerLavery
    Member
    Posted 7 years ago #

    Thank you! I'll give that a go.

Topic Closed

This topic has been closed to new replies.

About this Topic