1. Home
  2. Knowledge Base
  3. WordPress
  4. Change the text of a password-protected WordPress page

Change the text of a password-protected WordPress page

When you add a password to a WordPress page, the text above the password field is generated automatically and you cannot change it in the backend.
Our approach helps to correct the sometimes poor translation.

There are two methods to change the text of a password-protected page:

Plugin – “Change Password Protected Message”

The text can be changed with this plugin
Change Password Protected Message
https://wordpress.org/plugins/change-password-protected-message

Code customization in the functions.php

The message can be changed by code. You must insert this code into the “functions.php” file of the active theme.

function my_custom_password_form() {
		global $post;
		$label = 'pwbox-' . ( empty( $post->ID ) ? rand() : $post->ID );
		$output = '
		<div class="boldgrid-section">
			<div class="container">
				<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" class="form-inline post-password-form" method="post">
					<p>' . __( 'This content is password protected. This is a custom message. To view it please enter your password below:' ) . '</p>
					<label for="' . $label . '">' . __( 'Password:' ) . ' <input name="post_password" id="' . $label . '" type="password" size="20" class="form-control" /></label><button type="submit" name="Submit" class="button-primary">' . esc_attr_x( 'Enter', 'post password form' ) . '</button>
				</form>
			</div>
		</div>';
	return $output;
}
add_filter('the_password_form', 'my_custom_password_form', 99);

You can customize this text in the code above:
“‘This content is password protected. This is a custom message. To view it please enter your password below:”

Dieser Beitrag ist auch verfügbar auf: Deutsch (German)

Was this article helpful?

Related Articles

Submit a Comment

Your email address will not be published. Required fields are marked *

Published on - 29. Apr 2021
Modified on - 29. Mar 2024
Views - 96
Likes - 0

Do you need help?

Kontaktiere uns gerne :-)
Contact Support
Skip to content