2012-08-25 3 views
2

좀 프로필 필드를 숨길하는 데 도움이 될 수 있습니다 BuddyPress의 방법이 알고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

을 전달하는 방법을 잘 모르겠습니다

답변

0

예, 일부 필드를 프로필 페이지에서 숨길 수 있습니다.

먼저 테마 폴더의 edit.php로 이동하십시오. 텍스트 상자를 숨기려면 이름을 "전체 이름"으로 지정하십시오.

<?php if ('textbox' == bp_get_the_profile_field_type()) : ?> 
    <?php if ('Full Name' != bp_the_profile_field_name()) : ?> 
     <label for="<?php bp_the_profile_field_input_name(); ?>"><?php bp_the_profile_field_name(); ?> <?php if (bp_get_the_profile_field_is_required()) : ?><?php _e('(required)', 'buddypress'); ?><?php endif; ?></label> 
     <input type="text" name="<?php bp_the_profile_field_input_name(); ?>" id="<?php bp_the_profile_field_input_name(); ?>" value="<?php bp_the_profile_field_edit_value(); ?>" <?php if (bp_get_the_profile_field_is_required()) : ?>aria-required="true"<?php endif; ?>/> 
     <?php endif; ?> 
<?php endif; ?> 

위의 코드는 profile.php 파일로 동일하지만, 다른 라디오 버튼과 선택 박스 등

귀하의 전체 이름 프로파일 필드에 조건을 넣어 나는 조건이 동일한 경우 새로운 유일한되지 않습니다 넣어 것입니다 귀하의 프로필에 표시됩니다.

0

테마 기능으로이를 수행하는 방법이 있는지 잘 모르겠지만 편집 루프에서 쉽게 숨길 수 있습니다. 테마에 /buddypress/members/single/profile/edit.php 복사하고이 줄을 추가 :

<?php while (bp_profile_fields()) : bp_the_profile_field(); ?>

이 치라의 접근 방식과 비슷합니다 : 그냥이 라인 아래

<?php if ('Field Name' == bp_get_the_profile_field_name()) continue; ?>

을 래퍼 div를 포함하여 필드와 관련된 모든 것을 건너 뛸 것이므로 관계없는 HTML은 없습니다.

0

CSS를 사용하여 id selector로 특정 필드를 숨길 수 있습니다.

#field_1 { 
display:none; 
} 
#signup_username { 
display:none; 
}