Try:
while ( bp_profile_fields() ) : bp_the_profile_field();
if ( bp_get_the_profile_field_id() != 'ID # YOU WANT TO SKIP' && bp_get_the_profile_field_id() != 'ID # 2nd field YOU WANT TO SKIP' ) :
@shanebp, that worked perfectly! Thank you very, VERY much!!!
Oops… I just found a problem.
The good news is that I was able to successfully hide certain profile fields from being displaying (by modifying profile.php). That part works great. Also, I was able to hide the same fields from being displayed when a user goes to edit their profile.
However, the problem I just discovered is that if any of those fields that I’ve hidden (using the above code changes) are “required” fields, then when a user goes to the Edit Profile page, the following error message appears upon clicking the Save Changes button: “Please make sure you fill in all required fields in this profile field group before saving.”
Even though I’m certain those hidden fields have values in them, that error message appears and there’s no way to save changes.
Any solution to this?
Correction to my last post. I meant to say…
I was able to successfully hide certain profile fields from being displaying (by modifying profile-loop.php). And I was able to hide the same fields from being displayed when a user goes to edit their profile (by modifying edit.php).
NOTE: Both files are located in: /bp-templates/bp-legacy/buddypress/members/single/
I still need help figuring out how to avoid the above-mentioned “required fields” error message upon clicking the Save Changes button.
Hi SimpleOne, I’m working on the same problem here! I tried to hide some fields from the edit profile page . i tried <
div class="clear"></div>
<?php while ( bp_profile_fields() ) : bp_the_profile_field(); if ( bp_get_the_profile_field_id() != '15' ) :?>
<div<?php bp_field_css_class( 'editfield' ); ?>>
to hide profilefield 15 from the editing page, unfortunatly it doesnt work, can you maybe send me a duplicate of your edit.php file? you would help me big time 🙂
@commoneasy
I found another solution that was suggested by someone in a different thread I had opened. Instead of modifying the edit.php file, I simply put the following code inside my functions.php file in my child theme. (Or you could put it in bp-custom.php.)
Please be warned that this solution didn’t work when I tried it on my site running BP 1.9.1. (Even though my desired fields were successfully hidden by this solution, I still received a “required fields” error message after clicking the Save button.)
So, in order for this to work, you need to be running BP 2.0 +.
The below profile field ids 1, 32, and 48 correspond to the three fields I needed to hide from editing.
function simple_one_hide_some_profile_fields( $retval ) {
if( bp_is_profile_edit() ) {
$retval['exclude_fields'] = '32,48,1'; //field ID's separated by comma
}
return $retval;
}
add_filter( 'bp_after_has_profile_parse_args', 'simple_one_hide_some_profile_fields' );
Try inserting the following into your functions.php or bp-custom.php and see if it works. I modified my above code specifically to hide your profile field id 15.
function commoneasy_hide_some_profile_fields( $retval ) {
if( bp_is_profile_edit() ) {
$retval['exclude_fields'] = '15'; //multiple field ID's should be separated by comma
}
return $retval;
}
add_filter( 'bp_after_has_profile_parse_args', 'commoneasy_hide_some_profile_fields' );
Wow thanks a lot man!! This works perfect 😀 for the intrested people, i put the code from SimpleOne in this exact file: wwwroot/wp-content/plugins/buddypress/bp-templates/bp-legacy/buddypress-functions.php
Great! Happy to help. 🙂
Hi there, i have an additional question… can this be used to hide profile groups from the edit profile group tab ? I tried;
// commoneasy hide fields
function commoneasy_hide_some_profile_fields( $retval ) {
if( bp_is_profile_edit() ) {
$retval['exclude_fields'] = '15'; //multiple field ID's should be separated by comma
}
return $retval;
}
add_filter( 'bp_after_has_profile_parse_args', 'commoneasy_hide_some_profile_fields' );
// commoneasy hide groups
function commoneasy_hide_some_profile_groups( $retval ) {
if( bp_is_profile_edit() ) {
$retval['exclude_groups'] = '4'; //multiple field ID's should be separated by comma
}
return $retval;
}
add_filter( 'bp_after_has_profile_parse_args', 'commoneasy_hide_some_profile_groups' );
unfortunatly it didn’t work, i hope somebody can help!
Group exclusion doesn’t work on a single install for the moment (only on MS).
More advice on this here:
https://buddypress.trac.wordpress.org/ticket/5650