Has anyone had success passing drupal user variables (such as profile fields or user role) to a custom Disqus theme?

Disqus lists their comment variables but i don't see how they correspond to what's being passed to Disqus in the code below (lines 118 to 138 of disqus.module)

    // Inject the user data if it's available.
    if ($user->uid > 0) {
      $data['id'] = $user->uid;
      $data['username'] = $user->name;
      $data['email'] = $user->mail;
      $data['url'] = url('user/' . $user->uid, array(
        'absolute' => TRUE,
      ));

      // Load the user's avatar.
      $user_picture_default = variable_get('user_picture_default', '');
      if (isset($user->picture) && !empty($user->picture) && is_numeric($user->picture) && $file = file_load($user->picture)) {
        $data['avatar'] = !empty($file->uri) ? $file->uri : NULL;
      }
      elseif (!empty($user_picture_default)) {
        $data['avatar'] = variable_get('user_picture_default', '');
      }
      if (isset($data['avatar'])) {
        $data['avatar'] = file_create_url($data['avatar']);
      }
    }

Comments

kevinwalsh’s picture

Title: Passing drupal » Injecting user data in a custom Disqus theme via Disqus api
owen barton’s picture

Title: Injecting user data in a custom Disqus theme via Disqus api » Altering user data passed to Disqus SSO
Category: support » feature
Status: Active » Needs review
StatusFileSize
new376 bytes

Looked into this, and it seems like only the existing fields are supported by Disqus SSO. Instead we are going to alter the username (display name in Disqus) instead to add user profile data (location etc) as part of the displayed name.

Attached patch adds an alter hook to allow this without hacking disqus.module.

marcingy’s picture

Version: 7.x-1.9 » 7.x-1.x-dev
Status: Needs review » Needs work

Needs a re-roll but makes sense

Grayside’s picture

If need to change the display name, running this through https://api.drupal.org/api/drupal/includes%21common.inc/function/format_... would allow hook_username_alter() to be used.

Grayside’s picture

Status: Needs work » Reviewed & tested by the community

#2 worked with git apply just fine for me. Rather than take the approach I mentioned in #4, I used this hook to swap in the value added by the Realname module to the user object.

slashrsm’s picture

Status: Reviewed & tested by the community » Needs work

Looks ok. Would be nice to have api.php entry for this.

Grayside’s picture

Status: Needs work » Needs review
StatusFileSize
new1.17 KB

Reroll with a disqus.api.php file demonstrating realname integration via the new hook.

slashrsm’s picture

Status: Needs review » Needs work
Grayside’s picture

Status: Needs work » Fixed

Status misfire? :P

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

  • Commit 183f5c8 on 7.x-1.x, 8.x-1.x by slashrsm:
    Issue #1537548 by Owen Barton, Grayside | kevinwalsh: Added Altering...