Support » Plugins and Hacks » This post is password protected. Magazine Basic

  • Resolved Harty

    (@harty)


    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?

Viewing 10 replies - 1 through 10 (of 10 total)
  • 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!

    Thank you happywifenmama. Just the job.

    Glad I could help!

    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');

    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

    Thanks happywifenmama – that did it for me !

    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.

    Joel

    (@jneuenhaus)

    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.

    alpha_llama

    (@alpha_llama)

    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.

    Thank you for this…

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘This post is password protected. Magazine Basic’ is closed to new replies.