以下内容将向行操作添加“查看作者配置文件”链接(即,当您将鼠标悬停在用户名上时显示的链接):
add_filter (\'user_row_actions\', \'add_view_author_page\', 10, 2) ;
function
add_view_author_page ($actions, $user)
{
$href = esc_attr (get_author_posts_url ($user->ID)) ;
$actions[\'add_view_author_page\'] = "<a href=\'$href\'>View author page</a>" ;
return ($actions) ;
}
Edit:
或者,如果希望在表的列中有链接,可以执行以下操作:
add_filter (\'manage_users_columns\', \'users_columns\') ;
add_filter (\'manage_users_custom_column\', \'users_custom_column\', 10, 3) ;
function
users_columns ($cols)
{
$cols[\'author_page\'] = \'Author page\' ;
return ($cols) ;
}
function
users_custom_column ($default, $column_name, $user_id)
{
if (\'author_page\' == $column_name) {
$href = esc_attr (get_author_posts_url ($user_id)) ;
$default .= "<a href=\'$href\'>View</a>" ;
}
return ($default) ;
}