WordPress.org

Ready to get started?Download WordPress

Forums

Change words "This post is password protected." (15 posts)

  1. DalesWife
    Member
    Posted 1 year ago #

    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!

  2. halty
    Member
    Posted 1 year ago #

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

  3. DalesWife
    Member
    Posted 1 year ago #

    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.

  4. esmi
    Forum Moderator
    Posted 1 year ago #

    @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');
  5. DalesWife
    Member
    Posted 1 year ago #

    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?

  6. DalesWife
    Member
    Posted 1 year ago #

    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!

  7. esmi
    Forum Moderator
    Posted 1 year ago #

    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.

  8. DalesWife
    Member
    Posted 1 year ago #

    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!

  9. esmi
    Forum Moderator
    Posted 1 year ago #

    What is in your .htaccess file?

  10. DalesWife
    Member
    Posted 1 year ago #

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

  11. esmi
    Forum Moderator
    Posted 1 year ago #

    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.

  12. DalesWife
    Member
    Posted 1 year ago #

    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.

  13. Wanderer
    Member
    Posted 1 year ago #

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

  14. janecraft
    Member
    Posted 1 year ago #

    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.

  15. janecraft
    Member
    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.