WordPress.org

Ready to get started?Download WordPress

Forums

Critique on my minor 'Private posts' hack, pleas (5 posts)

  1. bb01100100
    Member
    Posted 9 years ago #

    Hello,
    I noticed that if I make a private post, the post would not show on the publicly accessible pages, even if I was logged in.
    There seemed to be no solution in the forums, so I scratched around and made a minor change to wp-blog-header.php, to include the wp-includes/functions.php file.
    This allows wp-blog-header.php to call the get_currentuserinfo() function, which in turn sets the
    $user_ID variable which was not being set otherwise.
    The result is that wp-blog-header.php now correctly allows private entries to be shown, if the private posts author is logged in.
    I'm a total WordPress (& php) newbie, so I'd appreciate any feedback on whether including functions.php was actually a good idea... I'd hate to compromise my site by including a file I shouldn't have.
    (I downloaded and installed the 2004-11-23.tgz wordpress tarball just to check whether this issue was resolved, but it appears not to be).
    Any thoughts or comments gratefully received.
    Thanks,
    BakedBeans

  2. tinarenee
    Member
    Posted 9 years ago #

    BB,
    I'm really interested in this idea - as a newbie to php myself, I can't make any determinations on whether it's a good idea - but I can tell you that it didn't work for me! :( (I'm running 1.3a4) Hopefully a sage php person can pop in and let us know! Kudos to you for jumping in and giving it a go.
    Tina

  3. Elliott C. Bäck
    Member
    Posted 9 years ago #

    This seems like a bug that you fixed and not a hack--did you try submitting a patch into CVS, or talking to a dev?

  4. tinarenee
    Member
    Posted 9 years ago #

    BB,
    I'm running 1.3 alpha 4 and the Private Posts code to insert your code before isn't in the wp-blog-header.php file - it is in the 1.2 version.
    I couldn't get it to work. :(

  5. mjmd
    Member
    Posted 9 years ago #

    I have been playing around with this, and also can't get private posts to show.
    One thing I have discovered, at least in 1.3 alpha 5:
    If your main index.php file is not in the same directory as the main wordpress directory, then the variable $user_ID is not defined. If it is in the same directory, that value IS defined (as the ID of the currently logged in user). This certainly doesn't seem right.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.