Customize the Password Form on Protected Posts

This document is deprecated! The information on this page refers to a Thesis version that is now obsolete. Please visit the Thesis Docs for current documentation.

When you password protect a post in WordPress, a form is displayed prompting the reader to enter the password to view the post:

Default Password Form on Protected Post

Default Password Form on Protected Post

Using the WordPress filter the_password_form along with some custom code in your Thesis custom_functions.php file, you can modify various text elements in the password form. You can change the explanatory prompt message, the label of the password field, the text on the submit button — or all three of these at once.

Note that, in each of the following examples, the $after variable is what determines the replacement text — simply replace the example text contained inside each pair of single quotes with your own desired text (be sure to retain the single quotes themselves to avoid triggering a PHP syntax error).

Change Prompt Message โˆž

function custom_password_prompt($content) {
	$before = 'This post is password protected. To view it please enter your password below:';
	$after = 'Enter your password to view this post:';
	$content = str_replace($before, $after, $content);
	return $content;
}
add_filter('the_password_form', 'custom_password_prompt');

Change “Password” Text โˆž

function custom_password_text($content) {
	$before = 'Password:';
	$after = 'Custom Password Text:';
	$content = str_replace($before, $after, $content);
	return $content;
}
add_filter('the_password_form', 'custom_password_text');

Change Submit Button Text โˆž

function custom_submit_text($content) {
	$before = 'Submit';
	$after = 'Custom Submit Text';
	$content = str_replace($before, $after, $content);
	return $content;
}
add_filter('the_password_form', 'custom_submit_text');

Change All Three of the Above at Once โˆž

function custom_password_form($content) {
	$before = array('This post is password protected. To view it please enter your password below:','Password:','Submit');
	$after = array('Enter your password to view this post:','Custom Password Text:','Custom Submit Text');
	$content = str_replace($before,$after,$content);
	return $content;
}
add_filter('the_password_form', 'custom_password_form');
Customized Password Form on Protected Post

Customized Password Form on Protected Post