Archived topic
Code to disable url in comments
7 replies · Started by epickenyan on February 20, 2019
Hi. Could you kindly provide edited code from this one to only disable URL field in comments? I want only name and email to remain.
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']);
unset($fields['email']);
return $fields;
}
Hi there,
Try this:
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;
}
Let me know :)
It worked. Thanks.
You're welcome :)
My site https://www.54wzj.com
Code I'm using
add_filter( 'comment_form_default_fields', 'wzj_disable_comment_url', 10 );
function wzj_disable_comment_url($fields) {
unset($fields['url']);
return $fields;
}
Doesn't work for me https://www.54wzj.com/yuming/what-to-do-when-com-domain-is-registered/
I'm using GP 2.2.2, GP Premium 1.7.8
Use the code provided by Tom instead https://generatepress.com/forums/topic/code-to-disable-url-in-comments/#post-816071
Epic,
That works, thanks.
Why should the after_setup_theme action hook matter though?