How would I make this happen?

Any help would be greatly appreciated. Thank you ahead of time.

Comments

Taxoman’s picture

Version: 7.x-1.0-alpha1 » 7.x-1.x-dev

Some thoughts:
a) Drupal core has custom fields for the user account page. See under Configure -> User Account -> Manage Fields. You might achieve this by disabling the default user picture functionality and adding your own custom field to be used with this module. That may have other undesired side effects, though.

b) Potentially(?): also see this module: http://drupal.org/project/profile2

c) The Display Suite 7.x-2.x branch contains field permissions.
Its 7.x-1.x branch needs THIS module to support field permissions.
From the top of my currently tired mind, I am not sure if that is enough to provide roles-based access control to the core user picture field, though.
Check out http://drupal.org/project/ds

d) ctools' Page Manager has related roles-based access functionality for variants to override the user profile page, without dependency on other modules.
See: http://drupal.org/project/ctools

kziv’s picture

I solved it in a custom module as follows:

/**                                                                                                                                                                                                                           
 * Implements hook_permission().                                                                                                                                                                                              
 */
function csm_user_permission() {

  return array(
    'change own picture' => array(
      'title' => t('Change own picture'),
      'description' => t('Change own user picture'),
    ),
    'change any picture' => array(
      'title' => t('Change any picture'),
      'description' => t('Change any user picture'),
    ),
  );
}

/**                                                                                                                                                                                                                           
 * Implements hook_form_FORM_ID_alter() for form id user_profile_form.                                                                                                                                                        
 */
function csm_user_form_user_profile_form_alter(&$form, &$form_state, $form_id) {

  global $user;

  // Hide the picture field if the user doesn't have permissions to change it                                                                                                                                                 
  // This can't be done with field permissions                                                                                                                                                                                
  $is_own_profile = $form['#user']->uid == $user->uid;
  if (
    ($is_own_profile && !(user_access('change own picture') || user_access('change any picture')))
    || (!$is_own_profile && ! user_access('change any picture'))
  ) {
    $form['picture']['#access'] = FALSE;
  }

}
rooby’s picture

Issue summary: View changes
Status: Active » Fixed

Closing as this is old and has a solution.

It is also not really relevant to this module as the profile field is not a proper field that this module can control.

I would also recommend sticking with the drupal core profile pic field as it integrates with a lot of other modules.

Although if you want to use a custom field you can override the user picture display to use your field by overriding the themeing of user picture: https://api.drupal.org/api/drupal/modules!user!user-picture.tpl.php/7

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.