admin管理员组

文章数量:1279178

For a custom role, I've to remove/hide the email and URL fields in the author box inside the Edit Comment area in WP admin. Only the name field should be visible there.

I've to keep the URL and email field enabled for comments in the discussion settings, and can't hide the fields only on the frontend using CSS. They should be removed entirely from the source code of the page, so backend code which removes the fields would be the most likely approach.

Example URL of an edit comment page in WP admin: wp-admin/comment.php?action=editcomment&c=544499.

The form comes from wp-admin/edit-form-comment.php, which is called from wp-admin/comment.php. Can anyone suggest a way to remove the 2 fields from showing up in the form? Thanks.

For a custom role, I've to remove/hide the email and URL fields in the author box inside the Edit Comment area in WP admin. Only the name field should be visible there.

I've to keep the URL and email field enabled for comments in the discussion settings, and can't hide the fields only on the frontend using CSS. They should be removed entirely from the source code of the page, so backend code which removes the fields would be the most likely approach.

Example URL of an edit comment page in WP admin: wp-admin/comment.php?action=editcomment&c=544499.

The form comes from wp-admin/edit-form-comment.php, which is called from wp-admin/comment.php. Can anyone suggest a way to remove the 2 fields from showing up in the form? Thanks.

Share Improve this question edited Oct 23, 2021 at 19:37 sgro asked Oct 22, 2021 at 13:48 sgrosgro 1012 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

There is no filter hook to customize comment edit fields on admin page. However you can hide those two fields using CSS, add the code below on your active theme.

function wp_ste_remove_commentfields() {
    global $pagenow;
    if ( $pagenow != 'comment.php' ) return;
    ?>
    <style>
        .editcomment tr:nth-child(2),
        .editcomment tr:nth-child(3) {
            display: none;
        }
    </style>
    <?php
}
add_action( 'admin_print_styles', 'wp_ste_remove_commentfields' );

本文标签: How to remove some author fields from the edit comment page in wpadmin