News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Group permissions to modify CPF's set to "only admins can edit"

Started by hcfwesker, December 31, 2011, 12:14:53 AM

Previous topic - Next topic

hcfwesker

Add Permissions to edit "admin only" Custom Profile Fields

This is regarding the SMF 2 packed in feature Custom Profile Fields.

Allow other groups to edit custom profile fields set to "users can see this field, only admins can edit"  WITHOUT having to add the permission "Administrate forum and database" to that group.

The 4 options available, one really leaves you limited  "users can see this field, only admins can edit".  For those with CPF additions, that only admins are allowed to change, but also want to give another member of staff, or another member group the permissions as well.



I've asked for this several times since I upgraded to SMF 2, and kept being told it was either impossible, or would take serious modifications to get it to work.  Well, I found out how, and it's actually just a few simple modifications.


Sources/ManagePersmissions

Find
'profile_remote_avatar' => array(false, 'profile', 'use_avatar'),

Add After
'manage_cp_fields' => array(false, 'maintenance', 'administrate'),


Sources/Profile-Modify.php

Find
if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0))
continue;


Replace with
if ($row['private'] != 0 && !allowedTo('manage_cp_fields') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0))
continue;


Sources/Profile.php

Find
// Get the right restrictions in place...
$where = 'active = 1';
if (!allowedTo('admin_forum') && $area != 'register')


Replace with
// Get the right restrictions in place...
$where = 'active = 1';
if (!allowedTo('manage_cp_fields') && $area != 'register')




default/languages/ManagePermissions.php

add anywhere in the file before ?>
$txt['permissionname_manage_cp_fields'] = 'Modify Member Custom Profile Fields';
$txt['permissionhelp_manage_cp_fields'] = 'Allows this group to modify other Members Custom Profile Fields';



There are 2 different ways this permission works for those that are added



selecting Option #1 , in the pic, just allows the member to modify their own Custom Profile Fields set to users can see this field, only admins can edit".   ( this is useful if a member is in good standing and admins trust them to modify their own custom fields normally only admins are able to modify for members.

selecting both 1 & 2 , which seems best suited for staff members, will allow them to modify the custom fields on any members profile, to help with custom fields that only admins can modify for members.


Sure not many will have use for this, but the option is there for those who wanted this option as well.



rpalmer68

I've been searching around tonight as I need to allow my "Membership Moderator" membergroup to edit a number of custom profile fields that are currently set to "Only Admin can view".

So far the only useful result I have found is this one, but I am concerned about modifying these files as I assume then updates may be an issue further down the track.

So before I do this, is there another way of allowing a membergroup permissions to edit "admin only" custom profie fields?  Or is this maybe a new feature that is being considered and that I should wait for??

Thanks

hcfwesker

This is the only solution so far, that allows that to happen.   If you're qorried about an update later on, but need this now, then you can make the manual edits, and bookmark this page.  So, when you want to reverse them back to original edits, then use this and just do the edits backwards.

rpalmer68

Quote from: hcfwesker on April 02, 2012, 09:23:12 PM
This is the only solution so far, that allows that to happen.   If you're qorried about an update later on, but need this now, then you can make the manual edits, and bookmark this page.  So, when you want to reverse them back to original edits, then use this and just do the edits backwards.

Thanks, I have made the changes and it works perfectly.. well done!

I have posted a feature request to implement this in the live code.

http://www.simplemachines.org/community/index.php?topic=472942.0

Cheers

hcfwesker

You're welcome, bud.  i knew I couldn't have been the only one to want this for my site. 

Advertisement: