You are here

function disqus_user_load in Disqus 7

Implements hook_user_load().

File

./disqus.module, line 422
The Disqus Drupal module.

Code

function disqus_user_load($users) {

  // Check which Disqus domain to use.
  $domain = variable_get('disqus_domain', '');
  if (!empty($domain)) {
    foreach ($users as &$account) {

      // Only show on the profile if desired. Don't show on the administrator's profile.
      if (user_access('display disqus comments on profile', $account) && $account->uid != 1) {

        // Save the data to the user object.
        $account->disqus = array(
          'domain' => $domain,
        );

        // Build the absolute URL without the alias for the disqus_url flag.
        $account->disqus['url'] = url('user/' . $account->uid, array(
          'absolute' => TRUE,
        ));

        // Build the title.
        $account->disqus['title'] = check_plain(strip_tags($account->name));

        // Provide the identifier.
        $account->disqus['identifier'] = 'user/' . $account->uid;

        // Inject the script.
        if ($developer = variable_get('disqus_developer', FALSE)) {
          $account->disqus['developer'] = (int) $developer;
        }
      }
    }
  }
}