Drupal display name when logging in with Facebook

edited February 2015 in Drupal
I have the service all set up and working great. I am able to login with Facebook. However the name being displayed is a strange version of the user's Facebook name.

The user's FB name is "John Q Doe", but when logging in, Drupal is displaying the name as "john.doe"... any ideas why this is occurring? Can I change the parameters for this? Logging in with Google properly returns "John Doe" as the user.

Thanks!
Bill Setzer

Best Answer

  • Bob_DamanBob_DamanMemberModerator
    edited February 2015 Answer ✓
    Most people prefer not using their real names as user name. Whenver it's possible our system will gather their preferred username from the social network. Google doesn't provide a username, that's why the real names are used.

    You can change this behavior in the file social_login_core.module of the module.

    Please replace this code:

    // Forge User Login. $user_login = ''; if (!empty($identity['preferredUsername'])) { $user_login = $identity['preferredUsername']; } elseif (!empty($identity['displayName'])) { $user_login = $identity['displayName']; } elseif (!empty($identity['name']['formatted'])) { $user_login = $identity['name']['formatted']; } else { $user_login = trim($user_first_name . ' ' . $user_last_name); }

    By

    // Forge User Login. $user_login = ''; if ( ! empty ($user_first_name) || ! empty ($user_first_name)) { $user_login = trim($user_first_name . ' ' . $user_last_name); }elseif (!empty($identity['preferredUsername'])) { $user_login = $identity['preferredUsername']; } elseif (!empty($identity['displayName'])) { $user_login = $identity['displayName']; } elseif (!empty($identity['name']['formatted'])) { $user_login = $identity['name']['formatted']; }

    Welcome!

    Please sign in to your OneAll account to ask a new question or to contribute to the discussions.

    Please click on the link below to connect to the forum with your OneAll account.