How to hide and disable URL and email fields from comments?

Question

After further research I found some relevant functions. Keep in mind it’s probably better to separate these into different functions, and if your WordPress theme gives you any trouble, check this out.

// disable url field
function disable_comment_url($fields) {
    if(isset($fields['url']))
        unset($fields['url']);
    return $fields;
}

add_filter('comment_form_default_fields', 'disable_comment_url');

// disable email field
function disable_comment_email($fields) {
    if(isset($fields['email']))
        unset($fields['email']);
    return $fields;
}

add_filter('comment_form_default_fields', 'disable_comment_email');

Also be sure to visit Settings >> Discussion and uncheck the “Comment author must fill name and email” option to avoid user comments being rejected upon submission.

0
Jesse Nickles 1 month 2022-08-21T12:22:39-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse