Directory Hooks

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.

Google Apps Login is trusted by thousands of organizations from small businesses to NASDAQ-listed companies and government organizations.
Users click their way through Login via Google (just one click after the first time)

Users click their way through Login via Google (just one click after the first time)

You can try it out by clicking below to auto-create a test account on this site! This will show you the basic Google login process.
Try out Google login
 

Logging in is only the start – Google Apps Login takes care of all your WordPress user management. Find out more here.

[user_show_avatar]

See [user_first_name] – that was easy!

Your account has been created, and you are now logged in. On your own site, you will specify your Google Apps domain – e.g. mycompany.com – and only users on that domain will be allowed to auto-create accounts.
Logging in is only the start – Google Apps Login takes care of all your WordPress user management.
Find out more

×