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:

/*-----------------------------------------------------------------------------------*/
/* 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' );

Revisions

Tags: , ,

No comments yet.

Leave a Reply