Linked profile custom field

Since it was top of mind, I decided to spend some personal time this evening trying to make a generalized custom module for this functionality. I want to give it another review and test later, so I’ll share it hereafter.


@gccervone One observation for your implementation:

// setup search and read people profiles from group
$data_type	= 'profiles';
$args		= ['tid' => 2, 'filter' => 'gid|equals|' . $_LW->_GET['id']];
$people 	= $_LW->read($data_type, $args);

Like gid, tid doesn’t seem to be a valid widget argument. I tried using your code in an example, and the $_LW->read was giving me all profiles in the group.

If you want just profiles of a single type, then the following should work:

$data_type	= 'profiles';
$args		= [
				'filter' => [
					'tid|equals|2',
					'gid|equals|'.$_LW->_GET['id']
				]
			];
$people		= $_LW->read($data_type, $args);

In the example based on your use case, I assumed that the coordinator could either be faculty or staff, which Beloit has as two separate types. Thus, for the example, I used this approach in order to get both types at once.

$data_type	= 'profiles';
$args		= [
				'type' => ['Faculty','Staff'],
				'filter' => 'gid|equals|'.$_LW->_GET['id']
			];
$people		= $_LW->read($data_type, $args);

Aside: If interested more than one profiles by tid, using just filter in a single $_LW->read isn’t possible, I think. Filter mode is either “match all” or “match any”, neither of which work for a mixed request like “group and (faculty or staff)”. Would either have to use to the type argument– which is fine for types like employee profiles given the name should never change– or make multiple reads with different arguments and merge the results.