WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Post passwords and custom functions (2 posts)

  1. lonewolfonline
    Member
    Posted 5 years ago #

    Hi,

    I have a page template which displays content on the left and thumbnails on the right. Thumbnails are generated using a custom php function and data extracted from the custom fields.

    When I password protect the post the content is correctly hidden using the_content - please enter password, but I need some code for the thumbnails.

    Something like:

    IF password_protected AND password_entered_correct
    {
    show thumbnails
    }
    else
    {
    please enter password
    }

    Anybody know how to do this? Is there a global for the password which I can compare to post_password?

    I am currently using

    if (empty($post->post_password)) {

    to hide content, but using this it never gets shown.

    Thanks in advance

    Tim

  2. lonewolfonline
    Member
    Posted 5 years ago #

    Having trawled through some of the core files if found this way for testing. Hopefully this will be helpful to somebody else.

    if ( (empty($post->post_password)) || ($_COOKIE['wp-postpass_'.COOKIEHASH] == $post->post_password) )
      {
    show thumbnails
    }
    else
    {
    please enter password
    }

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags