• WordPress 4.9.6 includes a checkbox in the comment field to let the user choose whether to save their name/email address/website for future comments, rather than just doing that automatically. This is great, but I need to be able to modify the message shown with that checkbox: I have disabled the website/URL field, so that part of the message makes no sense. I’d also like to say explicitly that saving the info places a cookie and remind visitors of how they can modify their cookie preferences if they want to delete that cookie later.

    How can I do this? I assume I can override the text from functions.php, but I have no idea how.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    This is set in code as

    <label for="wp-comment-cookies-consent">' . __( 'Save my name, email, and website in this browser for the next time I comment.' )

    So, that’s a translatable string which you can “translate” with the gettext filter. See https://codex.www.ads-software.com/Plugin_API/Filter_Reference/gettext

    Thread Starter Ate Up With Motor

    (@ate-up-with-motor)

    Hmm. I tried this:

    add_filter( 'gettext', 'theme_change_comment_cookie_label', 20, 3 );
    function theme_change_comment_cookie_label( $translated_text, $text, $domain ) {
        if ( is_singular() ) {
            switch ( $translated_text ) {
                case 'Save my name, email, and website in this browser for the next time I comment.' :
                    $translated_text = __( 'Set a cookie to save my name and email to use for future comments.', 'frontier' );
                    break;
            }
        }
        return $translated_text;
    }

    … but it breaks the site, so something is wrong. Maybe the case is wrong?

    Thread Starter Ate Up With Motor

    (@ate-up-with-motor)

    Nope, I’m wrong — it did work. I’m getting a linebreak between the checkbox and the message (visible here), but the message is correct.

    Thank you I have used this code and it works but one question.

    Not sure about frontier in code I believe it should be ‘theme_text_domain’ which is the name of your theme’s text domain.

    Please can someone tell me what I should change it to?

    Keith

    Done a bit more research and I needed to change to name of the theme.

    Keith

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Customize comment checkbox?’ is closed to new replies.