Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Add comment_meta to wp_comment_reply

Considering WP hooks capabilities the only way to set extra content here is to reorganize reply/edit form itself, using hooks.

An example below demonstrates how to add extra HTML content on “reply” form. Find out “HERE IS YOUR CUSTOM CONTENT” label inside code to check where magic happens.

add_filter('wp_comment_reply', 'test_reply_comment_func', 10, 2);

function test_reply_comment_func($str, $input) {
    extract($input);
    $table_row = TRUE;
    if ($mode == 'single') {
        $wp_list_table = _get_list_table('WP_Post_Comments_List_Table');
    } else {
        $wp_list_table = _get_list_table('WP_Comments_List_Table');
    }
    // Get editor string
    ob_start();
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close');
    wp_editor('', 'replycontent', array('media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings, 'tabindex' => 104));
    $editorStr = ob_get_contents();
    ob_end_clean();`

    // Get nonce string
    ob_start();
    wp_nonce_field("replyto-comment", "_ajax_nonce-replyto-comment", false);
    if (current_user_can("unfiltered_html"))
        wp_nonce_field("unfiltered-html-comment", "_wp_unfiltered_html_comment", false);
    $nonceStr = ob_get_contents();
    ob_end_clean();


    $content="<form method="get" action="">";
    if ($table_row) :
        $content .= '<table style="display:none;"><tbody id="com-reply"><tr id="replyrow" style="display:none;"><td colspan="' . $wp_list_table->get_column_count() . '" class="colspanchange">';
    else :
        $content .= '<div id="com-reply" style="display:none;"><div id="replyrow" style="display:none;">';
    endif;

    $content .= '<div id="replyhead" style="display:none;"><h5>Reply to Comment</h5>'
            . '<p style="margin:10px 0;"> HERE IS YOUR CUSTOM CONTENT</p>'
            . '</div>';


    $content .= '<div id="addhead" style="display:none;"><h5>Add new Comment</h5></div>
            <div id="edithead" style="display:none;">';

    $content .= '   
                <div class="inside">
                <label for="author">Name</label>
                <input type="text" name="newcomment_author" size="50" value="" tabindex="101" id="author" />
                </div>

                <div class="inside">
                <label for="author-email">E-mail</label>
                <input type="text" name="newcomment_author_email" size="50" value="" tabindex="102" id="author-email" />
                </div>

                <div class="inside">
                <label for="author-url">URL</label>
                <input type="text" id="author-url" name="newcomment_author_url" size="103" value="" tabindex="103" />
                </div>
                <div style="clear:both;"></div>';

    $content .= '</div>';

    // Add editor
    $content .= "<div id='replycontainer'>\n";
    $content .= $editorStr;

    $content .= "</div>\n";

    $content .= '           
            <p id="replysubmit" class="submit">
            <a href="#comments-form" class="cancel button-secondary alignleft" tabindex="106">Cancel</a>
            <a href="#comments-form" class="save button-primary alignright" tabindex="104">
            <span id="addbtn" style="display:none;">Add Comment</span>
            <span id="savebtn" style="display:none;">Update Comment</span>
            <span id="replybtn" style="display:none;">Submit Reply</span></a>
            <img class="waiting" style="display:none;" src="' . esc_url(admin_url("images/wpspin_light.gif")) . '" alt="" />
            <span class="error" style="display:none;"></span>
            <br class="clear" />
            </p>';

    $content .= '
            <input type="hidden" name="user_ID" id="user_ID" value="' . get_current_user_id() . '" />
            <input type="hidden" name="action" id="action" value="" />
            <input type="hidden" name="comment_ID" id="comment_ID" value="" />
            <input type="hidden" name="comment_post_ID" id="comment_post_ID" value="" />
            <input type="hidden" name="status" id="status" value="" />
            <input type="hidden" name="position" id="position" value="' . $position . '" />
            <input type="hidden" name="checkbox" id="checkbox" value="';

    if ($checkbox)
        $content .= '1';
    else
        $content .= '0';
    $content .= "\" />\n";
    $content .= '<input type="hidden" name="mode" id="mode" value="' . esc_attr($mode) . '" />';

    $content .= $nonceStr;
    $content .="\n";

    if ($table_row) :
        $content .= '</td></tr></tbody></table>';
    else :
        $content .= '</div></div>';
    endif;
    $content .= "\n</form>\n";
    return $content;
}

Result

enter image description here

Exaplanation.

This code overrides the default reply form code. The reply comment and edit comment internally connected. When you trigger to “quick edit” the <div> of .addhead and .edithead are visible, .replyhead – hidden. When you trigger to “reply” .addhead and .edithead are hidden, .replyhead – visible.

Related Posts:

  1. How to rearrange fields in comment_form()
  2. Removing the “Website” Field from Comments and Replies?
  3. How to add a class to the comment submit button?
  4. How to wrap submit button of comment form with div
  5. comments reply script not working
  6. How to display comment form error messages in the same page
  7. How do I set up real anonymous posting in bbpress forums? [closed]
  8. How to allow the reply link to remain on the comment form after I have reached my 10 nested comment limit?
  9. Deep customization of the comment form?
  10. Using filter to add additional fields to comment_form()
  11. Why are default comments deprecated?
  12. Comments Reply Form
  13. Does WordPress Allow Blank/Empty Comment Submissions In WordPress?
  14. Comment form not showing up without comments
  15. Programmatically block commenting by restricting view of comment form
  16. How can comments be submitted when I don’t have a comment box on a page?
  17. Custom Field Added In Comment Form Not Showing In Edit
  18. Add a drop down list to comment form?
  19. How To Remove The “Click here to cancel reply” Link From The WordPress Comment Form
  20. Making a Comment on a page without being on that page?
  21. customize comment form
  22. How to save new comment as custom comment type?
  23. WP comments form (custom) is displaying an extra comment field
  24. How to modify comments form using comment_form()?
  25. How to add consent checkbox in comment section
  26. How to add enctype to multipart/form-data to comment form?
  27. Changing position of cancel_comment_reply_link and other elements of comment form
  28. Publish a message on facebook after having posted a comment
  29. Edit Comment_Field while using T5 Comment Textarea On Top-Plugin
  30. Share comment to twitter after publishing [closed]
  31. Disable comments
  32. How to add attributes to the comment form tag?
  33. Comment form connection to Gravity Forms
  34. Auto-fill Custom comment fields
  35. The comment login form is visible to me but not to the user
  36. Change order of comment fields
  37. How to call my custom WordPress Comment form without getting the comments?
  38. Create comments.php form of custom HTML code
  39. How can I test why the comment hook is not working?
  40. How can I convert anonymous commenters into registered users?
  41. comment_post action hook running on page load instead of after a comment is posted
  42. Add class to comment form div when comment-reply button is clicked
  43. To whom do emails get sent via the WordPress comments form?
  44. blank page after submitting a comment
  45. Display complete comment section via post ID
  46. Notification if Comment Author Field is left empty. E.g. change input border colour
  47. Assign author to comment from post edit page
  48. How to retain comment text on comment form after login/registration?
  49. Check if comment was successfully submited
  50. Get Post ID within wp_set_comment_status hook
  51. Ajax submit comments
  52. WordPress for questions and responses website
  53. Why could my comment_form variable not be working?
  54. Display avatar with comment form?
  55. How to make comments private for commentor and post author
  56. Name of comment field differs on different sites
  57. comment_notes_before not working
  58. How to create post comment from different domain
  59. Get comment id of the individual comments in comment list when modifying comment posted using comment text filter
  60. How can I embed comments plugin to my own website?
  61. Custom comment field not showing when logged-in
  62. Comments on future posts
  63. get_comment_meta not behaving as expected
  64. unsetting required fields in the comment reply form
  65. Returning error upon comment being flagged as spam
  66. Clicking Comment “Reply” Button only replies to first comment
  67. How to filter comments by comment_meta
  68. Changing the Comment Fields using Filter (without success)
  69. Cannot Remove Title Reply from Custom Comment Template for Signup Page
  70. comment just attachment .. reply just text … can I do that?
  71. Custom sort comments with select form
  72. Edit Comments Fields
  73. Same comment section on every page
  74. Update post “A” on comment submition on post “B”
  75. Upload avatar for post comment
  76. How to display replies to his comments in user profile of current user
  77. reply comment below the comment box without reload page
  78. Comment author profile image
  79. Force to show all fields in comment forms to the logged-in users
  80. Top rated posts Average rating issue
  81. Comment Form Fields when user logged in
  82. Author name length character limit?
  83. Check if comment author has url
  84. How to make comment reply available only for login members of a certain user roles only?
  85. How to call out the date of user’s first comment?
  86. How to pass settings to comment_form() if theme only uses comments_template()?
  87. edit comments in front end
  88. How to replace anonymous comment form with a registration form on wordpress?
  89. How to add a class to comment submit button?
  90. WordPress Commenting System User access and Security
  91. Comments.php is not getting called on main blog page
  92. How to enable truly anonymous posting in bbPress forums? [closed]
  93. Comment section not appearing on posts
  94. Echo out custom fields in comments
  95. reply to comment excerpt instead of author in comment title
  96. How to change comment-page-1#comment-25 to any string?
  97. Adding restrictions to open comments
  98. wp-editor-area textarea disapear on cancel-comment-reply-link click
  99. Comment form – different title if no comment yet
  100. Display Comment Form on dedicated Page for each post
Categories comments Tags comment-form, comments, post-meta
‘child_of’ in get_posts not working
Ideas on how to organize a project [closed]

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress