6

Below is a image of the WordPress admin user list:

All I want to do is add an extra column called add badges. Column value should be a link to a another page.

I tried editing core files but it ended up realizing it's a bad practice since, because if I make changes I will lose the changes with the next update.

What WordPress does is that it uses $wp_list_table = _get_list_table('WP_Users_List_Table'); to get the table and $wp_list_table->display(); to display the table.

How to add a field to the table and to extend the admin users list page?

4

2 回答 2

8

您需要过滤器manage_users_columnsmanage_users_custom_column.

来自屏幕选项的在用户主页上显示用户 ID 的代码:

add_filter( 'manage_users_columns', 'column_register_wpse_101322' );
add_filter( 'manage_users_custom_column', 'column_display_wpse_101322', 10, 3 );

function column_register_wpse_101322( $columns ) 
{
    $columns['uid'] = 'ID';
    return $columns;
}

function column_display_wpse_101322( $empty, $column_name, $user_id ) 
{
    if ( 'uid' != $column_name )
        return $empty;

    return "<strong>$user_id</strong>";
}
于 2013-08-31T18:42:42.540 回答
-4

我相信,如果您按照这些说明进行操作,您会得到您想要的:

http://justintadlock.com/archives/2009/09/10/adding-and-using-custom-user-profile-fields

于 2013-08-31T16:46:27.403 回答