onManagerFormat Handler – Using Profile-Defined Fields

Hello,

I have the following section in a onManagerFormat handler, where “magazine_issue” is a custom field:

   // if on the news manager and in certain group
   if ($_LW->page==‘news’ && $_SESSION[‘livewhale’][‘manage’][‘gid’]==123) {
      $format=str_replace('</fieldset>', '{<strong>Issue:</strong> |magazine_issue|}</fieldset>', $format);
   };

I am trying to do something similar with a profile type, using a profile-defined field:

   // if on the profiles manager for a profile type
   if ($_LW->page==‘profiles_list’ && $_LW->_GET[‘tid’]==321) {
      $format=str_replace('</fieldset>', '{<strong>Type:</strong> |profiles_323|}</fieldset>', $format);
   };

However, while default fields and custom fields work in this space, I can’t seem to get the profile-defined field to work. I assume it is possible with the correct variable name, but any names I tried (i.e. custom_profiles_323, etc.) doesn’t seem to lead to any results.

Any advice or direction?

Hi Nick,

I’m not 100% sure, but looking through some old custom code I think to get access to profile_XX fields in onManagerFormat, you also need to customize the assocaited onManagerQuery in order to pull it in.

Here’s something you might be able to use as a model:

public function onManagerFormatResults($handler, $results) { // post-processes manager results
global $_LW;
if ( ($_LW->page=='profiles_list' || $_LW->page=='profiles_archive') && !empty($_LW->_GET['tid']) && $_LW->_GET['tid']==7) { // if on the tid=7 profiles manager
  foreach($results as $key=>$val) { // loop through manager results
    if (!empty($val['custom_18'])) { // if Graduation Year field is set
      $results[$key]['name']=$val['custom_18'].': '.$val['name']; // append it to name
    };
  };
};
return $results;
}


public function onManagerQuery($handler, $query) { // post-processes manager queries
global $_LW;
if ( ($_LW->page=='profiles_list' || $_LW->page=='profiles_archive') && !empty($_LW->_GET['tid']) && $_LW->_GET['tid']==7) { // if on the tid=7 profiles manager
  $query->fields('livewhale_profiles_fields.value AS custom_18'); // select Graduation Year
  $query->leftJoin('livewhale_profiles_fields', 'livewhale_profiles.id=livewhale_profiles_fields.pid AND livewhale_profiles_fields.fid=18'); // join profile fields
};
return $query;
}

Hope this helps!