• Resolved fredhead

    (@fredhead)


    I need to remove a few columns from the Users list page (users.php) on the admin pages in WordPress. I see how to add columns, both in the forum here and looking at the code base. What I don’t see is a way to selectively “unset” columns or otherwise remove columns the way you can in other parts of the admin interface on other pages. Is there a way to do this?

    I do see a class in this file:

    wp-admin/includes/class-wp-users-list-table.php

    Specifically, a get_columns function and single_row function in the WP_Users_List_Table class within this file.

    Are there actions/filters that can pre-empt and redefine which columns appear on the Users list page (users.php)? Or do I have to manually edit a core file in WP?

    Thanks for any direction.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter fredhead

    (@fredhead)

    After hours of fruitless searching, I hacked an answer from here:

    https://wordpress.stackexchange.com/questions/3233/showing-users-post-counts-by-custom-post-type-in-the-admins-user-list

    Specifically, the code that removes the Posts column from the User panel (users.php) is:

    add_action('manage_users_columns','remove_user_posts_column');
    function remove_user_posts_column($column_headers) {
        unset($column_headers['posts']);
        return $column_headers;
    }

    What’s frustrating (and interesting) is that the manage_users_columns action is not documented anywhere in the Codex or similar places online. Yet they parallel actions available for Post and Page column lists, for example, manage_page_columns and manage_page_custom_columns. Turns out there also is a manage_users_custom_columns action, as well, which is easier to find examples of online.

    Hopefully this will be useful to someone over time, as well.

    Most helpful!

    I’m using this to remove some default columns from the edit posts screen.

    function my_columns_filter( $columns ) {
        unset($columns['author']);
        unset($columns['tags']);
        unset($columns['categories']);
        unset($columns['tags']);
        unset($columns['comments']);
        return $columns;
    }
    add_filter( 'manage_edit-post_columns', 'my_columns_filter', 10, 1 );

    You can use this with custom post types by adjusting the filter like so:
    manage_edit-%customposttype%_columns

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Remove Columns from the User Admin List Page?’ is closed to new replies.