For me also not:
I tried it with
Mitglieder-Kategorie (Team oder Fan?)
instead of
'name of your field'
as well as with
'Mitglieder-Kategorie (Team oder Fan?)'
But my users can still change the values for this field. –
I tried as well – already before and now again – this code of @noizeburger:
//hide the user role select field in edit-screen to prevent changes after registration
add_filter("xprofile_group_fields","bpdev_filter_profile_fields_by_usertype",10,2);
function bpdev_filter_profile_fields_by_usertype($fields,$group_id){
//only disable these fields on edit page
if(!bp_is_profile_edit())
return $fields;
//please change it with the name of fields you don't want to allow editing
$field_to_remove=array("User Role");
$count=count($fields);
$flds=array();
for($i=0;$i<$count;$i++){
if(in_array($fields[$i]->name,$field_to_remove))
unset($fields[$i]);
else
$flds[]=$fields[$i];//doh, I did not remember a way to reset the index, so creating a new array
}
return $flds;
}
It works neither with
"Mitglieder-Kategorie (Team oder Fan?)"
nor with
Mitglieder-Kategorie (Team oder Fan?)
nor with:
'Mitglieder-Kategorie (Team oder Fan?)'
To make a field uneditable, you can remove it from the edit page of each profile.
You just have to enter the file ID, separated by coma if necessary to hide more than one.
Add snippet to child-theme functions.php or bp-custom.php
function bpfr_make_profile_field_uneditable( $retval ) {
if( is_user_logged_in() && bp_is_profile_edit() ) {
$retval['exclude_fields'] = '20,21,22'; // field id's
}
return $retval;
}
add_filter( 'bp_after_has_profile_parse_args', 'bpfr_make_profile_field_uneditable' );
Reference:
Using bp_parse_args() to filter BuddyPress template loops
Still it does not work; my users can still editing their entire profiles:
http://1a-spielwiese.de/wp-content/uploads/2014/10/Weiterhin_editierbar_8-10-14.jpg
And that’s my bp-custom.php:
http://1a-spielwiese.de/wp-content/uploads/2014/10/bp-custom_8-10-14.jpg
2 is the field “Geburtsjahr”
124 is the field “Mitglieder-Kategorie (Team oder Fan?)”
and 134 is the field “Geburtstag”.
I have tried it as well with ‘2’ only – also not working.
@crazyboy:
Did any of the proposals work for you?
@1a-spielwiese hi, @danbp ‘s solution is working perfectly for me in my functions.php
thank you a lot @danbp 🙂
You’re welcome @doremdou!