Works with WordPress Version 3.4.1
On password protected pages, WordPress presents the user with default text. In order to customize this text, just enter the code below in your functions.php file in your theme folder. I like to add custom code to the bottom of my theme files and give them a note (In this case the ‘Add Custom PW Protection Text’ line) so I can remember which code is which. Be sure to add the code BEFORE your final ?>.
Last tip–ALWAYS make a copy of your original php file before altering it. This will allow you to quickly revert back if something goes awry. I like to simply copy and paste in a TextEdit document so I can easily delete it once I no longer need it. This simple task has SAVED me many a time from having to figure out what piece of code I added that may or may not be working.
// Add Custom PW Protection Text
function my_password_form() {
global $post;
$label = ‘pwbox-‘.(empty($post->ID) ? rand() : $post->ID);
$output = ‘<div>
<p>’ . __(‘This content is password protected. Please enter your password below:’) . ‘</p>
<form action=”‘ . get_option(‘siteurl’) . ‘/wp-login.php?action=postpass” method=”post”>
<p><label for=”‘ . $label . ‘”>’ . __(‘Password:’) . ‘ </label> <input name=”post_password” id=”‘ . $label . ‘” type=”password” size=”20″ /> <input type=”submit” name=”submit” value=”‘ . esc_attr__(‘Submit’) . ‘” /></p></form></div>’;
return $output;
}
add_filter(‘the_password_form’,’my_password_form’);