Add sortable user signup date column to admin all users page in Wordress
Add below code in your active themes functions.php or custom plugin file
function new_modify_user_table( $columns ) {
$columns['registration_date'] = 'Date of registration';
return $columns;
}
add_filter( 'manage_users_columns', 'new_modify_user_table' );
function new_modify_user_table_row( $val, $column_name, $user_id ) {
$date_format = 'j M, Y H:i';
switch ($column_name) {
case 'registration_date' :
return date( $date_format, strtotime( get_the_author_meta( 'registered', $user_id ) ) );
break;
default:
}
return $val;
}
add_filter( 'manage_users_custom_column', 'new_modify_user_table_row', 10, 3 );
function rb_users_column_sortable( $columns ) {
return wp_parse_args( array( 'registration_date' => 'registered' ), $columns );
}
add_filter( 'manage_users_sortable_columns', 'rb_users_column_sortable' );
Comments
Post a Comment