[resolved] [closed] Change default text in a password protected page? (5 posts)

  1. dtlyme
    Posted 4 years ago #

    Hi - I just would like to customize the default text that shows when a page is password protected:
    Password Protected Page

    Where and how would I do that?

    many thanks-

  2. esmi
    Forum Moderator
    Posted 4 years ago #

    Try adding something like:

    function my_password_form() {
    	global $post;
    	$label = 'pwbox-'.(empty($post->ID) ? rand() : $post->ID);
    	$output = '<div class="password-form">
    	<p class="protected-text">' . __('This post is password protected. To view it, please enter your password below:') . '</p>
    	<form action="' . get_option('siteurl') . '/wp-pass.php" method="post">
    	<p><label for="' . $label . '">' . __('Password:') . ' </label> <input name="post_password" id="' . $label . '" type="password" size="20" /> <input type="submit" name="submit" value="' . esc_attr__('Submit') . '" /></p></form></div>';
    	return $output;

    to your theme's functions.php file

  3. dtlyme
    Posted 4 years ago #

    As always thank you Esmi. You are a great teacher and that worked beautifully! I made a 'custom-functions.php' and used your code. Perfection!

  4. esmi
    Forum Moderator
    Posted 4 years ago #

    Glad I could help :-)

  5. Wanderer
    Posted 3 years ago #

    The form action points to a wp-pass.php file which does not exist in current versions of WordPress.

Topic Closed

This topic has been closed to new replies.

About this Topic