12% off of LTD using this coupon: TWELVEPERCENTOFF. Promo ends on 2 Dec midnight UTC.
Published on Mar 5, 2021

How to customize the Password Protected Form in WordPress

Sridhar Katakam

If you are looking to change “This content is password protected..”, “Password” and “Enter” text for protected posts/Pages, add this sample code in a Code Snippet and modify as needed:

add_filter( 'the_password_form', 'custom_password_form' );
function custom_password_form( $output ) {	
	$original_strings = array( 'This content is password protected. To view it please enter your password below:', 'Password:', 'Enter' );
	$translated_strings = array( 'Este contenido está protegido por contraseña. Para verlo introduce tu contraseña a continuación:', 'Contraseña:', 'ENTRAR' );
	
	return str_replace( $original_strings, $translated_strings, $output );
}

Before:

After:

For full control the entire form’s HTML could be changed, like this.

References

https://wordpress.org/support/topic/how-to-change-the-warning-text/#post-11059203

https://diythemes.com/thesis/rtfm/password-protected-form/

tagschevron-leftchevron-rightchainangle-rightangle-upangle-downfolder-omagnifiercrossmenuchevron-down