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.
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: