Support » Plugins » Overridng the Protected Posts Form HTML?

  • I’m trying to override the Protected Posts form with my own HTML. A new hook was added in 2.7 to supposedly allow this. However, I think it might be a little broken, or I’m misunderstanding how it works.

    I’ve created a new function in my functions.php:

    function get_the_password_form_new() {
    	global $post;
    	$label = 'pwbox-'.(empty($post->ID) ? rand() : $post->ID);
    	$output = '<form class="inlinepassword" action="' . get_option('siteurl') . '/wp-pass.php" method="post">
    	<fieldset><legend>Password protection</legend>
    		<p>' . __("This Job Description is password protected. To view it please enter your password below:") . '</p>
    		<label for="' . $label . '">' . __("Password:") . '</label>
    		<input name="post_password" id="' . $label . '" type="password" size="20" />
    		<button type="submit" id="submit">OK</button>
    	return $output;

    As you can see, I’ve changed the HTML from the original function (in wp-includes\post-template.php). However, the resulting HTML that’s generated from my new function has a bunch of extra elements that I didn’t specify, and they are in a very odd order! This is what gets generated:

    <form class="inlinepassword" action="http://local.natsel/wp/wp-pass.php" method="post">
    <fieldset><legend>Password protection</legend></p>
    <p>This Job Description is password protected. To view it please enter your password below:</p>
    <p><label for="pwbox-16">Password:</label></p>
    <input name="post_password" id="pwbox-16" type="password" size="20" />
    <button type="submit" id="submit">OK</button><br />

    As you can see, there is an incorrect closing P tag that’s been introduced after my Legend. There is a new P element created around the label which I don’t want, and a BR element after the button.

    Where are these extra elements coming from? Why is one of them not constructed properly?

    Any tips would be appreciated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Anyone?

    How about I rephrase my query 🙂

    What function in WordPress causes extra line breaks and paragraph tags to be created, and how do I disable its use on password protect forms?

    I found out about wpautop and tried removing it using a filter on password form hook, but nothing changes.

    I’d really appreciate any tips you can share, this is driving me nuts. Thanks! 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Overridng the Protected Posts Form HTML?’ is closed to new replies.