WordPress.org

Ready to get started?Download WordPress

Forums

3.0 Compliant Version of the Extra Comment Fields Plugin (21 posts)

  1. justbishop
    Member
    Posted 3 years ago #

    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!

  2. Shifra
    Member
    Posted 3 years ago #

    THANK YOU!!

  3. thellwig
    Member
    Posted 3 years ago #

    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 ( ` ).

  4. MikeRW
    Member
    Posted 3 years ago #

    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>
  5. thellwig
    Member
    Posted 3 years ago #

    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.

  6. MikeRW
    Member
    Posted 3 years ago #

    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] => fake@yahoo.com
        [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
    )
     </div>

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

    <?php
       $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(http://www.hivegaming.net/images/comments.png) 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>
        </div>
       <?php }
    ?>
  7. thellwig
    Member
    Posted 3 years ago #

    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; ?>
  8. thellwig
    Member
    Posted 3 years ago #

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

  9. MikeRW
    Member
    Posted 3 years ago #

    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.

  10. thellwig
    Member
    Posted 3 years ago #

    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?

  11. MikeRW
    Member
    Posted 3 years ago #

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

  12. thellwig
    Member
    Posted 3 years ago #

    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.

  13. MikeRW
    Member
    Posted 3 years ago #

    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.

  14. thellwig
    Member
    Posted 3 years ago #

    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?

  15. MikeRW
    Member
    Posted 3 years ago #

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

  16. thellwig
    Member
    Posted 3 years ago #

    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.

  17. thellwig
    Member
    Posted 3 years ago #

    I understand that is is frustrating, but I honestly don't know what else to do to solve your problem. I've installed and written custom code for this plugin on two different sites and both times it's worked like a dream. I'm really sorry Mike. :(
    Maybe someone else more knowledgeable will stumble across this thread and point out something we've both been missing...

  18. MikeRW
    Member
    Posted 3 years ago #

    Hopefully, I'm not sue what's going on with it. I've tried reinstalling the plugin and every step except removing the wp-comments table (I have important comments I can't lose). I will continue to try to figure it out but for now I have too many other issues on the site to worry about this one. I'm just going to link the author name for now until I can figure this out. I really appreciate all of your help so far, thank you for your patience.

  19. maxemil
    Member
    Posted 3 years ago #

    If you get an error saying depricated php function, don't panic it will still work. However if you do want to fix it, at line 285
    replace the "ereg" with a preg_match

    //  if (ereg('^([a-zA-Z0-9_-])+$', $_POST['new_var'])) {
        if (preg_match('/^([a-zA-Z0-9_-])+$/', $_POST['new_var'])) {
  20. solace10
    Member
    Posted 3 years ago #

    Hey folks

    I've reworked the old plugin and updated it with comprehensive instructions and documentation.

    It's very easy to install and get going to add new comment form fields.
    I've modelled it around the twentyten theme, however, it's been tested on many other themes too. Works with 2.92 - and everything up to the current version (3.03 at time of writing)

    I've also added some additional features:
    - ability to show or hide additional comment fields on posts
    - ability to show extra comment fields in the admin email
    - and more!

    I'm not giving it away - it's just $15 - which goes towards my time supporting and maintaining it. I'm working on a revamped version for 2011.

    Meanwhile, the current version works just fine. If you'd like to take a look, go here: http://www.solaceten.info/extra-comment-fields-plugin

    Best regards
    Solace

  21. thellwig
    Member
    Posted 3 years ago #

    Mike, this is probably way too late for you, but for anyone else who encounters your problem as I just have, here's how to fix it:

    In your code, find the line that is fetching the comments. It will look similar to this:
    $comments = get_comments("post_id=$post_id");

    Now, right after this line, before you actually do anything with the comments, add this line:
    $comments = ecf_getComments( $comments, $post_id );

    Just one note here, in the second block of code, the second parameter $post_id is a variable that I previously defined in my code. You will have to change that in your code to reflect whatever the id of your actual post is.

    If you're inside The Loop, that's easy enough. If not, here's the code that I used to get the ID for the current post outside of The Loop:

    global $wp_query;
    $post_id = $wp_query->post->ID;

    Hope this helps someone.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.