W3 Mind Logo
Home » Customize the Password Form on Protected Posts WordPress

Customize the Password Form on Protected Posts WordPress

WordPress has a feature or functionality in which you can make your page password protected.
Basically this page contains site owner’s and user’s confidential things. Which is not to be shared with the normal users.

It’s very easy to make a page password protected in WordPress. All you have to do is go to “Visibility” option and select “Password Protected” option and type the password.

Password protected option

Some people want to customize the password form. So here are some functions for you and with the help of which you can customize the password form.

Change Prompt Message

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

Change Prompt Message

				
					function custom_password_text($content) {
	$before = 'Password:';
	$after = 'Entry Key:';
	$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 = 'Enter';
	$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('This content is protected. To view it please use your entry key below:','Entry Key:','Enter');
	$content = str_replace($before,$after,$content);
	return $content;
}
add_filter('the_password_form', 'custom_password_form');
				
			

Example:

About Author
Picture of W3Mind

W3Mind

W3Mind focuses on Blogging, Make Money Online, SEO, Business Blogging, Social Media, WordPress, Internet Tools, Web Design and Development.
Give it a Share
Facebook
Twitter
LinkedIn
You May Also Like
How to
START A
BLOG
(step by step)
Load WordPress Sites in as fast as 37ms!