我知道 BuddyPress 中有一种方法可以帮助隐藏一些配置文件字段:
function bp_has_profile( $args = '' ) {
global $profile_template;
// Only show empty fields if we're on the Dashboard, or we're on a user's profile edit page,
// or this is a registration page
$hide_empty_fields_default = ( !is_network_admin() && !is_admin() && !bp_is_user_profile_edit() && !bp_is_register_page() );
// We only need to fetch visibility levels when viewing your own profile
if ( bp_is_my_profile() || bp_current_user_can( 'bp_moderate' ) || bp_is_register_page() ) {
$fetch_visibility_level_default = true;
} else {
$fetch_visibility_level_default = false;
}
$defaults = array(
'user_id' => bp_displayed_user_id(),
'profile_group_id' => false,
'hide_empty_groups' => true,
'hide_empty_fields' => $hide_empty_fields_default,
'fetch_fields' => true,
'fetch_field_data' => true,
'fetch_visibility_level' => $fetch_visibility_level_default,
'exclude_groups' => false, // Comma-separated list of profile field group IDs to exclude
'exclude_fields' => false // Comma-separated list of profile field IDs to exclude
);
$r = wp_parse_args( $args, $defaults );
extract( $r, EXTR_SKIP );
$profile_template = new BP_XProfile_Data_Template( $user_id, $profile_group_id, $hide_empty_groups, $fetch_fields, $fetch_field_data, $exclude_groups, $exclude_fields, $hide_empty_fields, $fetch_visibility_level );
return apply_filters( 'bp_has_profile', $profile_template->has_groups(), $profile_template );
}
我不确定如何调用此方法并传递 'exclude_fields' => $IDs_to_hide