PDA

View Full Version : How To Hide (cannot edit) Profile Fields From Specific Groups With Conditionals


Jake Bunce
Sat 21st Jan '06, 4:45pm
This mod allows you to hide specific profile fields from specific usergroups on the edit profile / options pages. This picture shows an example of a profile field on one of these pages:

17901

In either of the below cases, you need to edit the appropriate template which corresponds to the type of profile field you are restricting:

Admin CP -> Styles & Templates -> Style Manager -> « » -> User Profile Field Templates

For example, if you want to restrict a Single-Line Text Box profile field, then you need to edit the userfield_textbox template.

Specify Which Groups Can Edit

Surround the contents of the appropriate template with this conditional code:


<if condition="THIS_SCRIPT != 'profile' OR (!in_array($profilefield[profilefieldid], array(A, B, C)) OR is_member_of($bbuserinfo, X, Y, Z))">

...

</if>


Where X, Y, Z is a comma list of usergroupids that are allowed to edit profilefieldids A, B, C.

You can view the usergroupids of each usergroup in your:

Admin CP -> Usergroups -> Usergroup Manager

Each usergroup has a menu on the right with a default selection of Edit Usergroup (id: X). The X is the usergroupid of that usergroup. For example, if you want usergroupid 5 to be able to access the profile fields in question, then you would replace X, Y, Z with 5 if that is the only group that has access.

You can view the profilefieldids of each profile field in your:

Admin CP -> User Profile Fields -> User Profile Field Manager

For example, a profile field that says field2 has a profilefieldid of 2, so you would replace A, B, C with 2 if that is the only profile field you want to restrict.

Specify Which Groups CANNOT Edit

Simply add a ! to the previous code to reverse the logic on the group checking:


<if condition="THIS_SCRIPT != 'profile' OR (!in_array($profilefield[profilefieldid], array(A, B, C)) OR !is_member_of($bbuserinfo, X, Y, Z))">

...

</if>


Where X, Y, Z is a comma list of usergroupids that are NOT allowed to edit profilefieldids A, B, C.

You can view the usergroupids of each usergroup in your:

Admin CP -> Usergroups -> Usergroup Manager

Each usergroup has a menu on the right with a default selection of Edit Usergroup (id: X). The X is the usergroupid of that usergroup. For example, if you want usergroupid 5 to NOT be able to access the profile fields in question, then you would replace X, Y, Z with 5 if that is the only group that DOES NOT have access.

You can view the profilefieldids of each profile field in your:

Admin CP -> User Profile Fields -> User Profile Field Manager

For example, a profile field that says field2 has a profilefieldid of 2, so you would replace A, B, C with 2 if that is the only profile field you want to restrict.