Support » Fixing WordPress » Change words "This post is password protected."

  • DalesWife

    (@daleswife)


    Theme: zbench

    I’ve posted on the theme support page but apparently nobody really uses this theme anymore – no replies!

    Wondering how to change the wording “This post is password protected. To view it please enter your password below:

    Nothing about password protection can be found in functions.php.

    I’m new to blogging, not a coder, but I’m sure this must be an easy fix. I’d include lines of code if I knew which ones might be helpful.

    Sorry if this isn’t enough info but I’m not sure what else to include here.

    Thanks in advance for any help you can give me!

Viewing 14 replies - 1 through 14 (of 14 total)
  • halty

    (@halty)

    Have a look in the wp-includes/post-template.php (around line 1221)

    DalesWife

    (@daleswife)

    I’ve checked all the templates and it is not in:
    page.php, functions.php, comments.php or single.php (which is titled “single post”).

    There is no post template.php listed.

    esmi

    (@esmi)

    Forum Moderator

    @halty: No! Never, ever, edit WordPress core scripts. And do not encourage others to do so. Editing core scripts can bring down your entire site and/or open security holes for hackers to use.

    @daleswife: Try adding the following to your theme’s finctions.php file – amended to suit your purposes:

    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;
    }
    add_filter('the_password_form','my_password_form');

    DalesWife

    (@daleswife)

    YES! YES! YES! It worked brilliantly! I’ve been googling for a full week and couldn’t figure it out – in fact, the only answer I found gave me a parse error. Thank you so, so very much!

    I notice the heading in bold “Protected: post name” is still just above my password instructions. Any chance you know how I can edit that? Since it’s pretty redundant saying it’s protected then just below telling them to enter a password?

    DalesWife

    (@daleswife)

    Uh-oh! Looks like there’s a slight problem since I made the change.

    When I’m on the page that I’ve protected (ex: mysite.com/unicorns) the user is prompted – with my all new custom password message – to enter their password. Previously, this would lead them to the full page which was still located at mysite.com/unicorns.

    Since making the change (with the code above), entering the password takes you to mysite.com/wp-pass.php which shows a 404 error.

    Help! The code DID do what I asked – allowed me to customize the wording of the password area, but now it isn’t leading users to the page they need to get to.

    Thanks again in advance!

    esmi

    (@esmi)

    Forum Moderator

    That could be due to something else in your theme. Try resetting your custom permalinks back to the default setting via Settings -> Permalinks. If this works, then review Using_Permalinks before setting a custom permalink structure back up again.

    DalesWife

    (@daleswife)

    I went into settings and changed permalinks back to the default. Now, after the password is entered, you no longer get a 404 – instead it leads you back to the home page. Any other suggestions?

    I really appreciate all your help with this!

    esmi

    (@esmi)

    Forum Moderator

    What is in your .htaccess file?

    DalesWife

    (@daleswife)

    I’m not sure what that is or where I would find it :/

    esmi

    (@esmi)

    Forum Moderator

    If it exists, it will be in your root WordPress folder. Do ensure that your FTP software is set to show all files as .htaccess files are often hidden by default.

    DalesWife

    (@daleswife)

    I found a file but there was very little in it. I can’t even be sure it was the htaccess file, since I don’t know what that is. Looks like I’m going to have to leave the default password working as is. I just don’t have the knowledge to find the areas I would need to get to.

    In the latest WordPress update, there is no wp-pass.php file that the script expects.

    Hello, I’m also having trouble with the code suggested above. It looks right, but the password returns a 404 error. I’ve added the code to a functions.php file in a child theme.

    Solution: look for /wp-pass.php in the code above and replace it with /wp-login.php?action=postpass. Thank you Wanderer for the tip and gsibert for the solution.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Change words "This post is password protected."’ is closed to new replies.