Im new to this drupal and php stuff but anyway, the problem is when a facebook user submits a new content(like a blog), I see "Submitted by (facebookuid)@facebook". Is there anyway to change this to directly print out the authors name? "(Submitted by (FacebookName)"
- Thanks in advance.

Comments

Dave Cohen’s picture

You can change the name of the account if you write a module that implements hook_fb. The operation is FB_OP_PRE_USER, and it's passed a data structure with a field 'username' which you can alter.

Or, you can override theme_username to display something more user friendly.

In either case, there is the potential problem of name collisions. If you change the name using hook_fb to a user name that is already used, the account will not be created correctly. If you change the displayed name with theme_username, you might display the same name for multiple users (which may not be a bad thing). But because the name collisions might cause problems for people, I have not yet tried to do anything about this.

If anyone wants to patch the fb_fbml theme to override theme_username I'd probably commit that patch.

Mark B’s picture

The override theme_username solution would work OK, but I'm guessing that this would involve a call to the Facebook API to get the Facebook name of the user. This could start to hurt performance on pages with lots of usernames (e.g. a node with lots of comments on).

My Drupal site uses the advanced profile module, which creates a user profile node for each user. I've written an implementation of hook_fb which catches the FB_OP_POST_USER operation, calls the Facebook API to get the Facebook name of the user, and stores it against the profile node as the node title. I've also had to override the node and comment theming to use the node title instead of the user name in the "Submitted by" text.

As an aside, I'm pretty sure this violates Facebook's terms of service: http://wiki.developers.facebook.com/index.php/Storable_Information. I suspect the only acceptable solution (from Facebook's TOS perspective) is to ask the user to enter their name again for the purposes of storing it in Drupal. However, that's clearly not so good from the user's perspective! Alternatively, you may be able to get away with some clever wording in your applications terms of service page - IANAL!

Dave Cohen’s picture

Mark, your understanding is right on. Here's a couple things you may not know...

fb_users_getInfo() gets basic information about users, and caches in the session. The idea is to avoid the overhead of asking facebook each time, while not completely violating the terms of service (if at all).

the new Facebook Connect will allow you to add XFBML to your pages. XFBML provides tags similar to fb:user. The browser runs javascript which contacts facebook to get the username and/or picture. This is facebook's official solution for this problem. fbConnect does not work for the general public, AFAIK, but you can work with it since you have the developer app installed.

The very latest modules include fb_connect, which is intended to support a number of fbConnect features, but so far the only thing I've worked on in resizable iframes.

Letharion’s picture

Status: Active » Closed (won't fix)

Since Drupal 5 is no longer supported, I'm taking the liberty to close all FB D5 support requests.