Forums

[resolved] Please help me find where I'm going wrong (WordPress expert needed) (5 posts)

  1. Johnny T
    Member
    Posted 2 years ago #

    Hi
    I've got a problem when I try and add a comment to a post. It doesn't let me unless I'm the Admin.

    It used to work until I did a major mod today which I'll try and explain in the hope that someone out there can point me in the right direction.

    There used to be 2 types of 'post_status' in the wp_posts db. They were "publish" and "draft". I needed a third option so used "pending".

    Now if I go to a "pending" post and go to add a comment the scripts bombs out (without error) at the following point in /wp-includes/comment-template.php

    function comments_template( $file = '/comments.php', $separate_comments = false ) {
    global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage;

    // ***********************************************
    // Script fails at the condition below and returns
    // This leaves just a blank screen
    // ***********************************************
    if ( ! (is_single() || is_page() || $withcomments) )
    return;

    Does anyone know why a post that has the post_status set to "pending" would fail that IF statement? (or maybe I'm off on the wrong track here and something else is causing that IF statement to fail???)

    *** UPDATE ***
    I've just done some error trapping and I've found that in the posts that it allows me to comment on the is_single() is a 1 where as the others there is no value in is_single().... so, does anyone know where is_single() gets set??
    *** END OF UPDATE ***

    Basically if I'm logged in as an admin I can write messages but anything else and I can't?

    Also, if I comment out the above statement I just get die ('Please do not load this page directly. Thanks!'); error from the /themes/mytheme/comments.php file.

    I've been tearing my hair out with this one all afternoon but I'm new to WordPress and not that experienced in php either so I'm hoping I'm just missing something simple.

    Any help (I mean any at all) will be really really appreciated

    Many thanks

    John

  2. Mark / t31os
    Moderator
    Posted 2 years ago #

    You'll have to pardon my blunt question... but, why would a 'pending' post/page be receiving comments?...

    Doesn't seem to make any sense that an un-published (i assume), post or page would be receiving comments..

  3. Johnny T
    Member
    Posted 2 years ago #

    Hi t31os

    I'm having to mod the site. I basically need 3 types of post (ones that ALL members of the site can comment on, ones that only people who have 'requested' and been 'approved' from the post owner can comment on, and then private ones that don't even show up on the site).

    I used to only have 2 types:
    For posts that anyone with the owners permissions could post I used "publish" as the post_status
    For posts that weren't seen on the site I used "draft" as the post_status

    Now I needed a third type and thought I could just use "pending" and then do the necessary mods in the code. This has worked out ok up until this issue I'm having now.

    Hope that explains... also, if you have any ideas of a better way of acheiving this then I'm all ears.

    Many thanks

    John ;-)

    PS. I've just updated my original post as I've found the source of the trouble now is "is_single()" not being set to '1'. Anyone know anything about this function, where it's set and how it might relate to my problem?? Thank you

  4. Mark / t31os
    Moderator
    Posted 2 years ago #

    Just use a decent search program...
    http://www.digitalvolcano.co.uk/content/textcrawler
    ** It's freeware **

    Search the WordPress files...

    That's how i track down functions, etc...

    I'm not fluent with the functions, but i'd guess that posts that are set as 'draft' or 'pending' do not get register as published (or should not at least), therefore, logically they should not be able to receive comments..

    Personally i'd avoid touching the existing wordpress tables, to avoid any upgrade problems... then write some custom tables to link into the posts table... and then adjust which posts are grabbed depending on whether information in said custom tables matches a value or one doesn't exist... etc... etc.. etc...

    In theory... (of course)..

    Most importantly i'd suggest avoiding modifying the posts table because you're just shooting yourself in the foot when it comes to upgrading WordPress later on... which you may wish to do for any number of (currently undeterminable) reasons.. :)

  5. Johnny T
    Member
    Posted 2 years ago #

    Hi t31os

    I've got a search program that I use but I couldn't find it... however, I've found it now and also tracked the problem down to query.php in the wp-includes folder. You were spot on when you said it was preventing pending posts from getting comments.

    Surprising what a break from the computer and a bite to eat can do!

    Many thanks

    John ;-)

Topic Closed

This topic has been closed to new replies.

About this Topic