最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Custom password form allows unlock two posts with the same password

matteradmin2PV0评论

I use this custom password form in my theme:

add_filter( 'the_password_form', 'custom_password_form' );
function custom_password_form() {
    $o = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" method="post">'.'
        <div class="l-password-protect">
            <div class="c-password-protect">
                <input name="post_password" id="password"  class="c-input" type="password" size="20" required placeholder="hasło"/>
                <input type="submit" name="Submit" class="c-button" value="' . esc_attr__( 'Submit', 'behold-universal-one' ) . '" />
            </div>
        </div>
    </form>
    ';
    return $o;
}

but when I have more than one post with the same password, after entered it I can unlock those two posts at once. Where's the problem?

EDIT

I modify my code based on this / but problem is still the same.

add_filter( 'the_password_form', 'custom_password_form' );
function custom_password_form($post = 0) {
    $post   = get_post( $post );
    $label  = 'pwbox-' . ( empty( $post->ID ) ? rand() : $post->ID );
    $output = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" class="post-password-form" method="post">
    <input name="post_password" id="' . $label . '" type="password" size="20" /></label> <input type="submit" name="Submit" value="' . esc_attr_x( 'Enter', 'post password form' ) . '" /></p></form>
    ';
return $output;
}
Post a comment

comment list (0)

  1. No comments so far