WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] This post is password protected. Magazine Basic (11 posts)

  1. Harty
    Member
    Posted 4 years ago #

    I have created a couple of pages that need passwords for users to access them.

    On the pages, viewers see the words: "This post is password protected. To view it please enter your password below:"

    I want to change this wording to something more appropriate for the page.
    I am using the latest Magazine Basic theme. Anyone know the name of the PHP file that these words appear on?

  2. happywifenmama
    Member
    Posted 4 years ago #

    You can change that in wp-includes/post-template.php around line 1141. Look for this: <p>' . __("This post is password protected. To view it please enter your password below:") . '</p>

    and change it to this:
    <p>' . __("Whatever you'd like it to say") . '</p>

    Keep in mind though that changing that text will change it globally, meaning whatever you change it too will appear on any post or page that is password protected.

    Hope that helps!

  3. Harty
    Member
    Posted 4 years ago #

    Thank you happywifenmama. Just the job.

  4. happywifenmama
    Member
    Posted 4 years ago #

    Glad I could help!

  5. garethooper
    Member
    Posted 4 years ago #

    Add the following to your Functions.php file under your theme folder:

    // Password Protected Page Message
    function custom_password_form($form) {
      $subs = array(
        '#<p>This post is password protected. To view it please enter your password below:</p>#' => '<p>Hopefully this works.</p>',
        '#<form(.*?)>#' => '<form$1 class="passwordform">',
        '#<input(.*?)type="password"(.*?) />#' => '<input$1type="password"$2 class="text" />',
        '#<input(.*?)type="submit"(.*?) />#' => '<input$1type="submit"$2 class="button" />'
      );
    
      echo preg_replace(array_keys($subs), array_values($subs), $form);
    }
    
    add_filter('the_password_form', 'custom_password_form');
  6. robcanyon
    Member
    Posted 4 years ago #

    I've followed the above steps and they've worked beautifully.

    thx.

    Is there anyway to make a hyperlink... ie

    Here's what I did. I think you can see the hyperlink I want

    ------

    This special information has been reserved for subscribers to this blog.

    For subscription details please visit http://www.escapetoprosperity.com/subscribe/.

    Your password details will be emailed to you in just a few minutes.

    Welcome to our community.

    -----

    thx,

    Rob

  7. minnellium
    Member
    Posted 4 years ago #

    Thanks happywifenmama - that did it for me !

  8. rsciw
    Member
    Posted 4 years ago #

    on a sidenote: Keep in mind that updates to that particular file
    wp-includes/post-template.php
    will be erased through WordPress updates, as it's one of the core files.

    The method suggested by garethooper therefore is better.

  9. Joel
    Member
    Posted 4 years ago #

    Thanks for the filter garethooper! Native WP hooks should be better documented in the codex, but I guess that's what the forums are for.

  10. alpha_llama
    Member
    Posted 4 years ago #

    ditto rsciw. I was just looking up how to change the default This post is password protected... to something different. Be best to keep things like this local to theme and not mess with the WP core files.

    Besides, he's right. An upgrade will wipe out all those customizations.

    Thanks garethooper.

  11. runawaygeek.com
    Member
    Posted 4 years ago #

    Thank you for this...

Topic Closed

This topic has been closed to new replies.

About this Topic