• I am password protecting certain pages with WordPress’ default password protect page status feature.

    I have a certain number to enter certain pages. Right now it is 77777. What I need to do is change that so site visitors can enter ANY number at all.

    I know this sounds weird. The reason I need to do this is because the site is for a beer distributor and he wants to just scare regular customers (non-liquor store owners) away from entering certain pages that include his prices to liquor stores. Ideally I would have it so people can enter their liquor license number but the problem is that there are always new licenses being issued so it would be hard to keep up with them.

    I need some help with code. I am not very good with php or javascript at all. But I am assuming I can change a line of php in a certain php file. I believe that ‘functions.php’ controls this feature. It may be another file.

    PLEASE HELP. Could someone tell me what code I have to change and what I have to change it to.

    Hopefully I gave enough details. Help would be greatly appreciated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    I don’t see a clean way to do this, the password check function does not provide any hooks one could leverage. The function get_the_content() makes a call to post_password_required(). You’d have to write your own version of this that is “looser” in its password checking and alter the core function definition to call your version instead.

    I cannot condone changing core code, so I’m not comfortable giving any more detail than I have already, sorry.

    I would create a custom metabox with a checkbox labeled “Password Protect”, and then in your page/single.php do something like:

    if(!get_post_meta($post->ID, '_protected', true) || isset($_GET['the-password'])) {
        the_content();
    }else{
        echo '<form method="GET">
            <input name="the-password">
            <input type="submit">
        </form>;
    }

    Here, the content would only be shown if either the page does NOT have the metabox checkbox checked OR if it does and they entered a password…any password. Otherwise, they will only be shown the password textbox.

    Thread Starter tmh2k1

    (@tmh2k1)

    Thanks so much for your help Oz.

    I should probably mention that my coding abilities are limited to HTML, CSS and WordPress. I am mainly a designer who also codes.

    Could you explain how to create a metabox as well as where the above text should exactly go?

    Thanks again Oz.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to change the password protect page feature to be a random number’ is closed to new replies.