Custom Message on Password-Protected Posts
Replaces the standard "This content is password protected" sentence with your own message, for example explaining how to get the password.
Opens WPIDE on
Code
// Message shown above the password field.
$wpide_password_message = 'This page is for clients only. Enter the password from your welcome email to continue.';
add_filter( 'the_password_form', function ( $output ) use ( $wpide_password_message ) {
$result = preg_replace( '/<p>.*?<\/p>/s', '<p>' . str_replace( array( '\\', '$' ), array( '\\\\', '\\$' ), wp_kses_post( $wpide_password_message ) ) . '</p>', $output, 1 );
return null === $result ? $output : $result;
} );
Notes
Basic HTML such as links is allowed in the message.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.