1

I am trying to configure Jetpack comments as following:

  1. I want to change the labels on the comment fields, but I have no idea where to find the code and edit the tags (they are also translated so I guessed I would cheat and change the translations. But I have already looked at my theme's translations, and the labels from the commenting form are just missing). In what other way I could do it? I would also like to add some html for what will follow (no3)*

  2. I also want to remove the Website field completely. One way is maybe hide it with css, but is there any other way of removing it completely?

  3. I want to limit the characters per comment between 20 and 500. I found two solutions. One is with a plugin by Greg, but I must temper with the theme files, which are quite chaotic (newspaper theme). The second is by adding the following code on my child theme's functions.php which I did:

    add_filter( 'preprocess_comment', 'wpb_preprocess_comment' );
    function wpb_preprocess_comment($comment) {
        if (strlen( $comment['comment_content'] ) > 500) {
            wp_die('This comment is too long! You can use up to 500 chars.');
        }
        if (strlen( $comment['comment_content'] ) < 20) {
            wp_die('This comment is too short! Write at least 20 characters.');
        }
        return $comment;
    }
    

    This solution works...kinda. It does stop commenters from submitting too long or too short comments, but when the message appears -covering just the form in an iframe-, and the form disappears. Or anyway I am unable to edit the comment. And i have to reload the page or go back and lose what I've written so far. Why does this happen, and how can I fix it?

Even better, how could I add a character counter somewhere near the form (*like an html span element, with id="count"), as in the example below, and provide a visual cue of what character limit is allowed? Then I would not have to throw the error message after preprocessing the comment. Maybe I could just disable the submit button, until the user is in limits again. (or is this a bad idea for usability?)

enter image description here

Τhe picture is from the greek newsportal website www.newsbeast.gr - the solution they have is probably custom, but I'm trying to recreate it to the best of my abilities. I have translated everything to help you get the point of the picture :)

The reason I am using jetpack comments is because it allows the users relatively easy, anonymous commenting and social commenting at the same time. I also use a third party plugin just for the thumb voting. I have researched tons of plugins, paid and free for the combination of these functionalities with no luck.

I have found some javascript code for the character counting part, I just don't know where to put the span. The code I found is:

document.getElementById('textarea').onkeyup = 
function({document.getElementById('count').innerHTML = 
        "Characters left: "+(500-this.value.length);};

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.