Site logo

Archived topic

Code to disable url in comments

7 replies · Started by epickenyan on February 20, 2019

Viewing posts 1–8 of 8

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 :)

Epic,

That works, thanks.

Why should the after_setup_theme action hook matter though?

This archived topic is closed to new replies.