[Resolved] Adding extra text in comments

Home Forums Support [Resolved] Adding extra text in comments

Home Forums Support Adding extra text in comments

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #632292
    Xavi

    Hi
    I’m trying to add some text after the submit comment button but it is not shown.

    
    function change_note_after_comment_form($defaults) {
        $defaults['logged_in_as'] = '<p class="comment-notes"> text 1 </p>';
        $defaults['comment_notes_after'] = '<p class="comment-notes"> text 2 </p>';
        return $defaults;
    }
    add_filter('comment_form_defaults', 'change_note_after_comment_form');
    

    “text 1” is correctly shown if I’m logged but “text 2” isn’t shown neither i’m logged or not.

    any ideas?

    GP Premium 1.6.2
    #632610
    Tom
    Lead Developer
    Lead Developer

    That’s strange – should be working.

    Try replacing this:

    add_filter('comment_form_defaults', 'change_note_after_comment_form');

    With this:

    add_filter('comment_form_defaults', 'change_note_after_comment_form', 99);

    #632744
    Xavi

    Hi
    Yes, it is extrange but it doesn’t work πŸ™
    I’m using Code Snippets.
    Another idea about why it is not working?
    Thanks

    You can see an example in https://vivirmindfulness.com/comer/aceptacion

    Now I have this active:

    function change_note_after_comment_form($defaults) {
        $defaults['logged_in_as'] = '<p class="comment-notes"> text 1 </p>';  //test to see if it is doing something
    	$defaults['comment_notes_after'] = '<p class="comment-notes"> text 2 </p>';
    	return $defaults;
    }
    add_filter('comment_form_defaults', 'change_note_after_comment_form',99);
    
    #632880
    Tom
    Lead Developer
    Lead Developer

    Try this:

    add_action( 'after_setup_theme', 'tu_change_comment_fields' );
    function tu_change_comment_field() {
        add_filter('comment_form_defaults', 'change_note_after_comment_form',99);
    }
    
    function change_note_after_comment_form($defaults) {
        $defaults['logged_in_as'] = '<p class="comment-notes"> text 1 </p>';  //test to see if it is doing something
    	$defaults['comment_notes_after'] = '<p class="comment-notes"> text 2 </p>';
    	return $defaults;
    }
    #632992
    Xavi

    πŸ™ Same output with your latest code.

    Now your suggestion is active in the web in case you need to check something.

    Thanks

    #633342
    Tom
    Lead Developer
    Lead Developer

    That’s so strange – it’s just a core WordPress filter, so it should work.

    Perhaps one of your plugins is overwriting it? Can you try deactivating them to rule out a conflict?

    #633539
    Xavi

    Strange issue, I have deactivate all plugins (except code snippets)and nothing changed.
    How can I debug it?

    #633702
    Tom
    Lead Developer
    Lead Developer
    #633771
    Xavi

    Hi Tom,

    I have edited the file /wp-content/themes/generatepress/comments.php . I haven’t a child theme.
    And it works!!!!
    It seems that the theme file overwrites Code snippets.

    Now that the reason is identified. There is any form to avoid changes in the comments.php file?
    I’m trying to avoid a child theme because I have never done πŸ™‚

    With comment_notes_after I can add some text after the comment box but I prefer to add the text after the submit button. Is it possible?

    Thanks

    #633955
    Xavi

    I have tryed this code

    add_action( 'comment_form_after', 'tu_change_comment_fields' );
    function tu_change_comment_fields() {
         echo '<p class="comment_text_after"> text after button xavi </p>'; 
    }

    To add some text after the submit button.

    It works, but, as I’m novice ;-), I don’t know if it is the correct way to do it or it could have collateral damages.

    Is it correct?

    Thanks

    #634186
    Tom
    Lead Developer
    Lead Developer

    I don’t see anything wrong with that function – nice find!

    I’ll get the original issue fixed in GP 2.2 πŸ™‚

    Thanks!

    #634504
    Xavi

    Thanks for your support Tom!!!

    #634652
    Tom
    Lead Developer
    Lead Developer
Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.