-
xiyang0630
Hello,
I want to ask how to remove the “Website” text field and edit this sentence “Save my name, email, and website in this browser for the next time I comment.”
Here is the screenshot: https://postimg.cc/ZBLHK5R2
Best Regards,
Yang
-
Hi Yang,
Those are WP settings, you will need to use WP’s filter for them:
1. Check this:https://docs.generatepress.com/article/remove-e-mail-and-url-field-from-comment-form/
If you only want to remove the website field, the code would be:
add_action( 'after_setup_theme', 'tu_add_comment_url_filter' ); function tu_add_comment_url_filter() { add_filter( 'comment_form_default_fields', 'tu_disable_comment_url', 20 ); } function tu_disable_comment_url($fields) { unset($fields['url']); return $fields; }
2. To edit the Save my name… try this PHP code:
add_filter( 'comment_form_default_fields', 'wc_comment_form_change_cookies' ); function wc_comment_form_change_cookies( $fields ) { $commenter = wp_get_current_commenter(); $consent = empty( $commenter['comment_author_email'] ) ? '' : ' checked="checked"'; $fields['cookies'] = '<p class="comment-form-cookies-consent"><input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes"' . $consent . ' />' . '<label for="wp-comment-cookies-consent">'.__('Remember Me!', 'textdomain').'</label></p>'; return $fields; }
Adding PHP: https://docs.generatepress.com/article/adding-php/
-
xiyang0630
Hello Ying,
After adding the second code to the snippet, Where can I edit the sentence of “Save my name, email, and website in this browser for the next time I comment”?
-
Alvind
Hi there,
To edit that, replace the “Remember Me” string inside the code with your preferred text.
-
xiyang0630
Hello Alvind,
I tried to replace the text of “Remember Me” before you replied to me. It’s changed nothing, Will it only affect on future posts?
Please take a look at the screenshot: https://postimg.cc/gallery/jSqdhqP
-
Alvind
In your code, the text is “Save my name, email, and website in this browser for the next time I comment”. Of course that will show up on the frontend.
-
xiyang0630
Hello Alvind,
I checked my text again. You can still take a look at my screenshot. It’s “Save my name and email in this browser for the next time I comment.”, not the original version of “Save my name, email, and website in this browser for the next time I comment.” I removed the text of “website”. You can take a look. By the way, the “website” text field is still there, I think there must be something wrong here. The code is correct, but I think there would be some error happened here.
-
Alvind
That’s odd. I can use the snippet without any issue. Is the snippet activated in the Code Snippet plugin?
If the issue persists, could you try adding the snippet to the
functions.php
file instead? -
xiyang0630
Hello Alvind,
This is what happened. Please take a look at screenshot: https://postimg.cc/JGdc2vjg
I do activated the snippet in the Code Snippet plugin.
-
Alvind
Deactivate the one you added inside Code Snippet first.
-
xiyang0630
Hello Alvind,
I think we’re closing to resolve the issue here. The text has been changed but the text field of “website” is still there. Give me 5 seconds to complain about “Am I cursed?”. I think the Code Snipppet plugin will be so easy to achieve my result. Before creating this case, I actually found the exactly same code on the Internet, but it didn’t work so that I came here ask for help. Why everyone can use Code Snippet plugin and make the snippet work except mine, Jesus..
-
Alvind
If adding the snippet into the
functions.php
file works but not in Code Snippets, you probably need to recheck the settings on the plugin. It should work because there is no error message when you add that snippet, right?Try adding this snippet to function.php as well:
add_action( 'after_setup_theme', 'tu_add_comment_url_filter' ); function tu_add_comment_url_filter() { add_filter( 'comment_form_default_fields', 'tu_disable_comment_url', 20 ); } function tu_disable_comment_url($fields) { unset($fields['url']); return $fields; }
-
xiyang0630
I reinstaill the plugin and added these two codes to the Snippet Code Plugin. Both works now.
Thank you a lot for helping me, Alvind.
Much appreciated.
-
Alvind
Awesome, glad to hear that!
- You must be logged in to reply to this topic.