admin管理员组

文章数量:1125625

I wan to add a date field to my user list dashboard where I can see list of new subscribers to my website along with the date they signed-up.

Thanks ~Vik

I wan to add a date field to my user list dashboard where I can see list of new subscribers to my website along with the date they signed-up.

Thanks ~Vik

Share Improve this question asked Jan 14, 2017 at 23:30 VikVik 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 1

This should be it

<?php 

function new_contact_methods( $contactmethods ) {
    $contactmethods['signupdate'] = 'Date';
    return $contactmethods;
}
add_filter( 'user_contactmethods', 'new_contact_methods', 10, 1 );


function new_modify_user_table( $column ) {
    $column['signupdate'] = 'Date';
    return $column;
}
add_filter( 'manage_users_columns', 'new_modify_user_table' );

function new_modify_user_table_row( $val, $column_name, $user_id ) {
  $user = get_user_by( 'id', $user_id );
  $date_formatted = new DateTime($user->user_registered);


    switch ($column_name) {
        case 'signupdate' :
            // return date_format($date_formatted, 'Y-m-d H:i:s');
            return $date_formatted->format('Y-m-d');

        break;
        default:
    }
    return $val;
}
add_filter( 'manage_users_custom_column', 'new_modify_user_table_row', 10, 3 );

本文标签: Add custom Date column to quotAll Usersquot admin panel in WP