Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author N-Media

    (@nmedia)

    Hi,

    Sorry, it does not remove comment fields, It suppose to add extra fields with comments.

    Thread Starter WPAddiction

    (@wpaddiction)

    Thank you for the quick response, just wanted to make sure that I wasn’t missing anything.

    Pete

    (@perthmetro)

    This should do the trick…
    1. Insert this into your functions.php

    // add default comment
    function rei_preprocess_comment($comment_data) {
        if ($comment_data['comment_content'] == '%dummy-text%') {
            $comment_data['comment_content'] = ''; // replace dummy text.
        }
        return $comment_data;
    }
    add_filter('preprocess_comment', 'rei_preprocess_comment');
    function rei_wp_footer() {
        ?>
        <script>
        jQuery(function($){
            var comment = $('textarea#comment');
            comment.removeAttr('required'); // remove required attribute of textarea.
            $('#commentform').on('submit',function(){
                if (comment.val() == '') {
                    comment.css('text-indent','-999px').val('%dummy-text%'); // change to dummy text.
                }
            });
        });
        </script>
        <?php
    }
    add_action( 'wp_footer', 'rei_wp_footer' );

    2. Use css to hide comment box

    Plugin Author N-Media

    (@nmedia)

    Thanks for sharing.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Remove Required Comment Textarea?’ is closed to new replies.