Google Apps Directory Hooks
Filters: gad_extract_user_data and gad_extra_output_fields
These hooks allows you to add your own fields to the Google Apps Directory’s search output. For example, you could add the following code to your functions.php file of your Theme, adding phone numbers to the output (note phone is available by default in the Enterprise version):
add_filter('gad_extract_user_data', 'my_gad_extract_user_data', 10,2); function my_gad_extract_user_data($user_outdata, $u) { // $u contains data returned from Google $phones = $u->getPhones(); if (is_array($phones) && count($phones) > 0) { $phone = $phones[0]['value']; // Add extra custom data for this user $user_outdata['phone'] = 'Phone: '.$phone; } return $user_outdata; } add_filter('gad_extra_output_fields', 'my_gad_extra_output_fields', 10,1); // Tell javascript widget extra fields to pull from the array extracted above function my_gad_extra_output_fields($infields) { return 'phone,'.$infields; }
If the filter gad_extract_user_data returns null, the user in question will be completely removed from the results displayed.
To add columns to the google-apps-directory-table (Enterprise version), to show different types of phone number (e.g. work, mobile,… )
function my2_gad_extract_user_data($user_outdata, $u) { $phones = $u->getPhones(); if (is_array($phones)) { foreach ($phones as $phone) { if (isset($phone['value']) && isset($phone['type'])) { $user_outdata[ 'phone_'.$phone['type'] ] = $phone['value']; } } } return $user_outdata; } add_filter('gad_extract_user_data', 'my2_gad_extract_user_data', 10, 2);
You could then add e.g. columns=”phone_mobile” to your google-apps-directory-table shortcode.