As the administrator of a site, I'd like to have information about a user that's not viewable or editable by that user. I'm fiddling with profile.module and tried simple_access.module, but they're not letting me do it. But I'm asking a lot.

I currently have two categories under Profiles: (1) Membership Info, and (2) Personal Info. I'd like to hide Membership Info from the users (dues paid, when subscribed, some notes about them that are for administrators only).

I realize I can choose "Private field, content only available to privileged users" but they, as THE user, the "owner" of that information, can still see it. I do want them to be able to see (and update/edit) their Personal Info, just not the Membership Info.

Yes, I guess I could just make a simple page (Membership Status) and hide it from them, but I'm hoping to have it integrated with the Profile module.

Thanks for any tips,

- Bradley

Comments

tostinni’s picture

Currently this function doesn't exists and I can't see an API to make the job, so consider write a patch to realize the job.
Create a new constant to define another PRIVATE method and create the hook_perm to set the rights to admins.

Well I don't think it's so hard, nor I am sure if it would be usefull enough to push this feature to core...

Try to get something working, with a little Drupal and php knowledge, I don't think this is so hard to achieve. Count with me to review your code.

kiz_0987’s picture

By coincidence I was just thinking about the need for this in profile.module, so there are probably a number of people interested. My desire for this feature is approx the same as for the first post, but to also allow the user to see, but not edit, a field. Membership Due Date is a good example -- I want my users to see when membership is due, and for me to be able to change it, but not for them to be able to change it.

Not sure if I'll get the chance to work on a patch, but wanted to show that there are more people interested in this functionality.

likoma’s picture

with a little Drupal and php knowledge

I can't even patch a module, much less create a patch! That said, I'm happy to try to help as much as a newbie can.

approx the same as for the first post, but to also allow the user to see, but not edit, a field.

See but not edit is fine, too.

Thanks for your responses and interest. I'll keep an eye on this thread to see if we catch some more interest.

- Bradley

pamphile’s picture

I'm also interested in this...

http://businessletters.com

jeffnovis’s picture

Hi,

I also had an entire profile category that I wanted to hide from users. My Drupal site caters for a family club and I have a 'Family relationships' profile category in which I, as administrator, keep a record of members' spouses and ancestors. I use this information to calculate how members are related to one another for display on my custom profile and members pages. I felt it was important to ensure that members couldn't alter any of these fields so I was looking for a way to hide the whole category. Eventually I solved the problem by amending one of the functions in profile.module.

Around line 385 there is a function called profile_categories() that returns an array containing titles of categories to display in profile pages. It looks like this:

function profile_categories() {
  $result = db_query("SELECT DISTINCT(category) FROM {profile_fields}");
  while ($category = db_fetch_object($result)) {
      $data[] = array('name' => check_plain($category->category), 'title' => $category->category, 'weight' => 3);  
  }
  return $data; 
}

I changed it so it only returns all profile categories if the user has admin access. For any other user, it returns all profile categories except 'Family relationships'.

function profile_categories()
{
  if (user_access('administer users'))
  {
    $result = db_query("SELECT DISTINCT(category) FROM {profile_fields}");
    while ($category = db_fetch_object($result))
    {
      $data[] = array('name' => check_plain($category->category), 'title' => $category->category, 'weight' => 3);
    }
  } 
  else
  {
    $result = db_query("SELECT DISTINCT(category) FROM {profile_fields} WHERE category!='Family relationships'");
    while ($category = db_fetch_object($result))
    {
      $data[] = array('name' => check_plain($category->category), 'title' => $category->category, 'weight' => 3);
    }
  }
  return $data; 
}

This had the desired effect. Users can no longer view or edit the 'Family relationships' category of their profiles, but administrators still have access.

Hope this helps someone.

Cheers,

Jeff

espirates’s picture

Will this still work for Drupal 6 ? I need this capability :)

brans041’s picture

I got this to work on Drupal 6.x but for some reason, there is still a category link that brings the user to a dead page. Is there a fix for removing this category link?

Thanks for your help in advanced.