Revision 244 is a pre-publication revision. (Viewing current revision instead.)

Password Protect & Custom Password Form 404

Taken from: http://tummel.me/wordpress-3-4-custom-password-form/

Are your password protected posts and pages broken since upgrading to WordPress 3.4?

Here is a little tip for anyone out there who may be using a custom password form to protect individual pages and posts. WordPress has this functionality built into its core but it is possible to customize the wording and look of your form. If you aren’t able to get into password protected posts anymore, you likely have a custom password form. This post isn’t a long description of how to make custom password forms, rather a helpful tip to fix your password protected posts and pages if they are no longer accessible since upgrading to WordPress 3.4. The core of the problem is that WordPress 3.4 has deprecated the use of wp-pass.php which was used in many custom password forms and replaced it with wp-login.php. Below is what a custom password form function is likely to look like, at least it’s what mine looks like:
add_filter( 'the_password_form', 'custom_password_form' );
Once you find it, replace 'wp-pass.php' with 'wp-login.php?action=postpass' you should fix your problem. Here the code I used to fix this issue in a partent theme I was using: [php]/*-----------------------------------------------------------------------------------*/ /* REMOVE THE CUSTOM PARTENT THEME PASSWORD PROTECT FORM */ /*-----------------------------------------------------------------------------------*/ function pp_custom_password_form() { global $post; $label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID ); $o = '<div class="clearfix"><form class="protected-post-form" action="' . get_option('siteurl') . '/wp-login.php?action=postpass" method="post"> ' . __( "<p>This post is password protected. To view it please enter your password below:</p>" ,'bonestheme') . ' <label for="' . $label . '">' . __( "Password:" ,'bonestheme') . ' </label><div class="input"><input name="post_password" id="' . $label . '" type="password" size="20" /><input type="submit" name="Submit" class="btn btn-primary" value="' . esc_attr__( "Submit",'bonestheme' ) . '" /></div> </form></div> '; return $o; } function pp_custom_password_form_setup() { remove_filter( 'the_password_form', 'custom_password_form' ); add_filter( 'the_password_form', 'pp_custom_password_form' ); } add_action( 'after_setup_theme', 'pp_custom_password_form_setup' );[/php]

Revisions

  • August 6, 2012 @ 12:43:25 [Current Revision] by PeterLugg
  • August 6, 2012 @ 12:38:55 by PeterLugg

Revision Differences

August 6, 2012 @ 12:38:55Current Revision
Content
 Added: Taken from: <a href="http:// tummel.me/wordpress-3-4-custom- password-form/" target="_blank" >http://tummel.me/wordpress- 3-4-custom-password-form/</a>
 Added: <h2>Are your password protected posts and pages broken since upgrading to WordPress 3.4?</h2>
 Added: Here is a little tip for anyone out there who may be using a custom password form to protect individual pages and posts. WordPress has this functionality built into its core but it is possible to customize the wording and look of your form. If you aren’t able to get into password protected posts anymore, you likely have a custom password form.
 Added: This post isn’t a long description of how to make custom password forms, rather a helpful tip to fix your password protected posts and pages if they are no longer accessible since upgrading to WordPress 3.4.
 Added: The core of the problem is that WordPress 3.4 has deprecated the use of wp-pass.php which was used in many custom password forms and replaced it with wp-login.php. Below is what a custom password form function is likely to look like, at least it’s what mine looks like:
 Added: <pre>add_filter( 'the_password_form', 'custom_password_form' );</pre>
 Added: Once you find it, replace 'wp-pass.php' with 'wp-login.php?action=postpass' you should fix your problem.
 Added: Here the code I used to fix this issue in a partent theme I was using:
 Added: [php]/*------ ------------- ------------ ------------- ------------ ------------- --------------*/
 Added: /* REMOVE THE CUSTOM PARTENT THEME PASSWORD PROTECT FORM */
 Added: /*----------- ------------- ------------ ------------- ------------ ----------------------*/
 Added: function pp_custom_password_form() {
 Added: global $post;
 Added: $label = 'pwbox-'.( empty( $post-&gt;ID ) ? rand() : $post-&gt;ID );
 Added: $o = '&lt;div class=&quot;clearfix&quot; &gt;&lt;form class=&quot;protected- post-form&quot; action=&quot;' . get_option('siteurl') . '/wp-login.php?action= postpass&quot; method=&quot; post&quot;&gt;
 Added: ' . __( &quot;&lt;p&gt;This post is password protected. To view it please enter your password below:&lt;/p&gt;&quot; ,'bonestheme') . '
 Added: &lt;label for=&quot;' . $label . '&quot;&gt;' . __( &quot;Password:&quot; ,'bonestheme') . ' &lt;/label&gt;&lt;div class=&quot;input&quot; &gt;&lt;input name=&quot;post_ password&quot; id=&quot;' . $label . '&quot; type=&quot;password&quot; size=&quot;20&quot; /&gt;&lt;input type=&quot;submit&quot; name=&quot;Submit&quot; class=&quot;btn btn-primary&quot; value=&quot;' . esc_attr__( &quot;Submit&quot; ,'bonestheme' ) . '&quot; /&gt;&lt;/div&gt;
 Added: &lt;/form&gt; &lt;/div&gt;
 Added: ';
 Added: return $o;
Deleted: Added: }
 Added: function pp_custom_password_ form_setup() {
 Added: remove_filter( 'the_password_form', 'custom_password_form' );
 Added: add_filter( 'the_password_form', 'pp_custom_password_form' );
 Added: }
 Added: add_action( 'after_setup_theme', 'pp_custom_password_form_setup' );[/php]

Note: Spaces may be added to comparison text to allow better line wrapping.

Tags: , ,

No comments yet.

Leave a Reply