没有可以用来更改名称列内容的直接筛选器。所以,为了得到您想要的,我们也应该删除“Name”列,并创建自己的Name列。因此modify_user_columns
功能如下
function modify_user_columns($column) {
$column = array(
"cb" => "<input type=\\"checkbox\\" />",
"wdm_name" => __(\'Name\'),
"email" => "E-mail",
"birthdate" => "Narozeniny",
"sleva_moto" => "Sleva moto"
);
return $column;
}
现在,我们有了一个控件,可以控制在名称列中显示什么。我们可以使用过滤器在该名称列中添加内容
manage_users_custom_column
.
add_filter( \'manage_users_custom_column\', \'wdm_display_name_with_edit_link\', 10, 3 );
function wdm_display_name_with_edit_link($content, $column_name, $user_object_id){
if ($column_name == \'wdm_name\' &&
current_user_can( \'edit_user\', $user_object_id) ) {
//get info of user
$user_object = get_userdata($user_object_id);
//generate edit link
$edit_link = esc_url( add_query_arg( \'wp_http_referer\', urlencode( wp_unslash( $_SERVER[\'REQUEST_URI\'] ) ), get_edit_user_link( $user_object->ID ) ) );
//Generate the complete Name with edit link
$content = "<strong><a href=\\"$edit_link\\">$user_object->first_name $user_object->last_name</a></strong><br/>";
} else {
//If logged in user does not have rights
//to edit users, just show Name of users
$content = "<strong>$user_object->first_name $user_object->last_name</strong><br />";
}
return $content;
}
现在,它将显示带有编辑链接的名称。希望这有帮助。:)