Found this issue http://drupal.org/node/289140 and then had a go at making it work for 6.X. I have it working and can make a module for all to test however there's one problem. When I request a relationship with a user the profile fields suddenly appear so it's not handling pending relationships. I've gotten further than I thought with this and it's almost there, hope someone can finish it off because I don't think I can do it.

function relationship_false($this_user, $that_user) {
  $params = array('between' => array($this_user->uid, $that_user->uid));
  $options = array('!pending_requests' => NULL, 'approved' => 1);
  module_load_include('inc', 'user_relationships_api', 'user_relationships_api.api');
  module_load_include('module', 'user_relationships_api', 'user_relationships_api');
  return user_relationships_load($params, $options, TRUE);
}
function profile_view_profile(&$user) {

  profile_load_profile($user);

  // Show private fields to administrators and people viewing their own account.
  if (user_access('administer users') || $GLOBALS['user']->uid == $user->uid) {
    $result = db_query('SELECT * FROM {profile_fields} WHERE visibility != %d ORDER BY category, weight', PROFILE_HIDDEN);
  } 
  else if (relationship_false($GLOBALS['user'], $user)) {
     $result = db_query('SELECT * FROM {profile_fields} WHERE visibility != %d AND visibility != %d ORDER BY category, weight', PROFILE_PRIVATE, PROFILE_HIDDEN);
  } 
  else {
    $result = db_query('SELECT * FROM {profile_fields} WHERE visibility != %d AND visibility != %d AND visibility != %d ORDER BY category, weight', PROFILE_PRIVATE, PROFILE_HIDDEN, PROFILE_RELATIONSHIP);
   }

'!pending_requests' => NULL I made that up, also tried 'pending' => 0 but am stabbing in the dark. This is what needs resolved though. BTW with this I intend to create an address book system i.e. load profile fields into address with those I have a relationship with.

Comments

OnlineWD™’s picture

Is simply matter of adding 'approved' => 1 to parameter array. I will try and make a module for this now ..

OnlineWD™’s picture

Trying to make module but cannot get this function to alter the state of the form after submitting it.

<?php
function custom_profile_relationships_form_profile_field_form_alter(&$form, &$form_state) {
  $form['fields']['visibility'] = array('#type' => 'radios',
    '#title' => t('Visibility'),
    '#default_value' => isset($edit['visibility']) ? $edit['visibility'] : PROFILE_PUBLIC,
    '#options' => array(
PROFILE_HIDDEN => t('Hidden profile field, only accessible by administrators, modules and themes.'), 
PROFILE_PRIVATE => t('Private field, content only available to privileged users.'), 
PROFILE_RELATIONSHIP => t('Relationships field, content shown on profile page for users who share a relationship with one another.'), 
PROFILE_PUBLIC => t('Public field, content shown on profile page but not used on member list pages.'), 
PROFILE_PUBLIC_LISTINGS => t('Public field, content shown on profile page and on member list pages.')),
  );
}?>

It alters the form but form remains unchanged after posting. If I edit profile.admin.inc directly using this code the form is altered after post.

mrf’s picture

Category: task » feature
Status: Active » Closed (won't fix)

Going to close this out. Profile fields are now a much different beast for D7 and I'm only doing bug fixes for 6.x.