How do I map "emails" and "organizations" info from LinkedIn to BuddyPress?

edited October 2018 in Questions

Hello,

I'm having difficulty properly pulling this information over. Here's what I have edited in my theme's function.php

function oa_social_login_store_xprofile ($user_data, $identity)
{
  do_action('bp_setup_globals');

  xprofile_set_field_data ('First Name', $user_data->ID, $identity->name->givenName);
  xprofile_set_field_data ('Last Name', $user_data->ID, $identity->name->familyName);
  xprofile_set_field_data ('LinkedIn', $user_data->ID, $identity->profileUrl);
  xprofile_set_field_data ('Location', $user_data->ID, $identity->currentLocation);
  xprofile_set_field_data ('Bio', $user_data->ID, $identity->aboutMe);
  xprofile_set_field_data ('Headline', $user_data->ID, $identity->note);
  xprofile_set_field_data ('Email', $user_data->ID, $identity->emails->value);
  xprofile_set_field_data ('Organization', $user_data->ID, $identity->organizations->name);
  xprofile_set_field_data ('Industry', $user_data->ID, $identity->organizations->industry);
  xprofile_set_field_data ('Position', $user_data->ID, $identity->organizations->title);
}
add_action( 'oa_social_login_action_after_user_insert', 'oa_social_login_store_xprofile', 10, 2);

Everything is working perfectly except for the last four - email, organization, industry, and position. What am I doing wrong?

Best Answer

  • Answer ✓

    I found the issue. It requires adding [0] after emails and organizations, i.e.:

    xprofile_set_field_data ('Email', $user_data->ID, $identity->emails[0]->value);
    xprofile_set_field_data ('Organization', $user_data->ID, $identity->organizations[0]->name);

Answers

  • Claude_SchlesserClaude_SchlesserAdministratorOneAll Team

    Hi Kenneth,

    thank you for the update. Yes emails and organizations are actually lists.

    You can find the full structure here:
    http://docs.oneall.com/api/basic/identity-structure/

    Regards,

  • Mish_12Mish_12Member

    Arcade games are timeless treasures that never fail to bring joy and excitement. Whether you're a seasoned gamer or just looking for some nostalgic fun, arcade games offer a perfect escape into a world of colorful characters, thrilling challenges, and endless entertainment. Visit here

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.