Support » Plugins » 3.0 Compliant Version of the Extra Comment Fields Plugin

  • As mentioned in THIS thread.

    Sorry, I allowed the domain where I uploaded the zip file to to lapse, and had someone contact me about not being able to download it today, so figured I’d come back and repost it (tried to do so in my original thread, but it was closed).

    So here’s the updated, WP 3.0 compliant version of the Extra Comment Fields plugin by Nate Weiner. Enjoy!

Viewing 15 replies - 1 through 15 (of 20 total)

    And don’t forget, during initial setup, to run this SQL code to create the necessary DB table!

    CREATE TABLE wp_comments_extra (
    comment_id BIGINT NOT NULL ,
    PRIMARY KEY ( comment_id )

    wp_comments_extra and both occurrences of comment_id should be put inside of backticks ( ` ).

    I need some help with this. The information is being written to the database but isn’t displaying on the site. Here’s my code, not sure why this isn’t working with the plugin as it was working when I manually entered the values into the actual comments database.

    <div style="margin:9px 0 0 75px;height:15px;width336px"><?php echo "$comment->comment_author"; ?><span style="float:right;margin-right:3px;"><a href="<?php echo "$comment->comment_author_url"; ?>"><?php echo "$comment->extra_sitename"; ?></a></span></div>

    Your tag name, in this case sitename needs to have the same capitalization as the tag that you entered in settings. So if in wp admin settings you called the tag Sitename then you’ll either need to change that tag to sitename or change your code to $comment->extra_Sitename

    That’s the most common point of confusion I’ve seen. It messed me up at first. If that doesn’t work you might try putting the code: `<?php print_r($comment); ?> where ever you want to see the comment and then paste the output from that function back here and I’ll take a look at it.

    Thanks for the reply, it’s not a case issue. I tried your suggestion and here is the result:

    <div>stdClass Object
        [comment_ID] => 84
        [comment_post_ID] => 276
        [comment_author] => Someone Youdontknow
        [comment_author_email] =>
        [comment_author_url] =>
        [comment_author_IP] => ???.???.???.???
        [comment_date] => 2010-10-24 17:21:13
        [comment_date_gmt] => 2010-10-24 21:21:13
        [comment_content] => One of the few low ping servers iv been too with such great performance, overall I love this server.
        [comment_karma] => 0
        [comment_approved] => 1
        [comment_agent] => Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.41 Safari/534.7
        [comment_type] =>
        [comment_parent] => 0
        [user_id] => 0

    I’m using some code to randomly display a testimonial, here’s the entire code if it helps:

       $post_id = 276;  // Put the 'testimonials' id here
       $comments = get_comments("post_id=$post_id&status=approve");
       if ($comments) {
         $ndx = mt_rand(1,sizeof($comments)) - 1;
         $comment = $comments[$ndx];
    	<div style="background:url( no-repeat;height:165px;width:336px">
        <div style="width:283px;height:120px;padding:12px 27px 0px 27px;font-size:90%;overflow:hidden;font-weight:bold"><?php echo "$comment->comment_content"; ?></div>
        <div style="margin:9px 0 0 75px;height:15px;width336px"><?php echo "$comment->comment_author"; ?><span style="float:right;margin-right:3px;"><a href="<?php echo "$comment->comment_author_url"; ?>"><?php echo "$comment->extra_sitename"; ?></a></span></div>
       <?php }

    So are all the normal comment fields being echoed fine?
    Also, what version of wordpress are you using? If it’s not 3.0.1 you might need to upgrade.
    Do you have the proper table created in your DB?
    If so, what is it named and what if any values does it hold?

    Also, the comment that you’re trying to display, was it submitted with the sitename field filled in?

    Id don’t know if it helps, but here’s my code and it works fine:

    <?php if($comment->extra_location != "") : ?>
    <small>Location: <?php echo $comment->extra_location; ?></small><br />
    <?php endif; ?>

    Oh, and something else, can you post the relevant code for the submit comment form? The problem might lie there.

    Here’s the code from the comments.php, it may indeed be something very simple but I’m having trouble tracking it down. All of the standard fields are fine it’s just the “extra” field from the plugin that isn’t working.

    <p><input type="text" name="sitename" id="sitename" size="22" />
    <label for="sitename"><small>Website Name (HiveGaming)</small></label></p>

    I tried your code and it appears the if statement is failing (I made sure to change location to sitename). It just seems like the new field isn’t being loaded into the array if that’s what it’s called.

    Your submit form is fine. Can you look at the DB table and see if the information is being saved into the table each time you submit a comment?

    It is. Here’s a screencap of the table(s) in PMA. I forgot to mention, I am indeed running WP 3.0.1

    There’s your problem. From the print_r() output that you gave me earlier, I see that you’re trying to display the comment that has the id of 84. If you look in the screenshot, you’ll see that the sitename field is blank for the row where comment_id is 84. So try filling in that field, and then see how it works.

    I had every field filled with dummy data earlier, I only edited the fields prior to taking the screencap. Also, in the print output earlier I changed the private data (email, name, IP). Other than that it’s all pretty much the same. If I create a field in the wp_comments table it will work fine. It just refuses to work from the wp_comments_extra table.

    Is there an easy way just to create the field in the original table and just add the new field manually to the array and forms?I tried to something along those lines earlier and just kept breaking the template.

    There may be a way to enter extra comment fields manually, but I’m not familiar with it.

    Does the output work once you filled in that field?

    No, during the last test before the screencap all fields were filled. I’ll try again though out of pure desperation 😛

    Ok, can you fill in the proper fields, and then repost the output of print_r() so I can see if that variable is even being loaded.

    Also, maybe (assuming this is test data and not important) you should empty the comments and comments_extra tables and then post a comment to them using your input form (not by entering it into the db manually).

    Then try reshowing that comment.

Viewing 15 replies - 1 through 15 (of 20 total)
  • The topic ‘3.0 Compliant Version of the Extra Comment Fields Plugin’ is closed to new replies.