最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Custom password form allows unlock two posts with the same password

programmeradmin3浏览0评论

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;
}
发布评论

评论列表(0)

  1. 暂无评论