官网找的代码:
//Adds Custom Column To Users List Table
function custom_add_user_id_column($columns) {
$columns['user_id'] = 'User ID';
return $columns;
}
add_filter('manage_users_columns', 'custom_add_user_id_column');
//Adds Content To The Custom Added Column
function custom_show_user_id_column_content($value, $column_name, $user_id) {
$user = get_userdata( $user_id );
if ( 'user_id' == $column_name )
return $user_id;
return $value;
}
add_filter('manage_users_custom_column', 'custom_show_user_id_column_content', 10, 3);
我自己修改的:
//Adds Custom Column To Users List Table
function custom_add_user_id_column($columns) {
$columns['user_id'] = '到期时间';
return $columns;
}
add_filter('manage_users_columns', 'custom_add_user_id_column');
//Adds Content To The Custom Added Column
function custom_show_user_id_column_content($value, $column_name, $user_id) {
$enddate = get_user_meta( $user_id, 'User_Time_Balance',true);
if ( 'user_id' == $column_name ){
if($enddate){
return $enddate;
}else{
return "未设置到期时间!";
}
}
}
add_filter('manage_users_custom_column', 'custom_show_user_id_column_content', 10, 3);
效果:
© 版权声明
THE END
暂无评论内容