Register with Twitter in Drupal 7

edited March 2016 in Drupal
I used the advice in to link fields from Facebook to my user profile data, works great, thank you.
Can anyone provide a method for bringing in the twitter homepage url to my field called field_twitter_home_url ?
A list of all available fields would be really helpful for us to adapt social data to our custom drupal profile fields.


  • Fred_PinelFred_PinelMember
    edited March 2016
    A good source for such information is the demo page, which would show a typical response.
    In our Drupal 7 plugin, you can see the following shorthands:
    $data = $social_data['response']['result']['data']; $identity = $data['user']['identity'];
    which should give you a start in addressing any field you see in the demo's response.

    So, for your question, that should be $identity["profileUrl"], as in:
    $profileurl = empty($identity['profileUrl']) ? '' : $identity['profileUrl']; $form['field_twitter_home_url'][LANGUAGE_NONE][0]['value']['#default_value'] = $profileurl;

    Hope this helps.
  • Yes, that's close, thank you. The one thing missing would be an if statement for populating that field if logging in with or adding a Twitter account.
    I am guessing $identity["profileUrl"] would return a value on several login methods.
  • Hi,
    Yes, this profileUrl is present on several social networks.
    Maybe that custom field could be more generic, maybe split in home page, and type (twitter, ...). Just a thought.
  • I am just looking for a method of applying profileUrl to the one twitter field if/when the Twitter method is being used. Can you offer advice for that?
  • Hi,
    Something like maybe:
    if ($identity['provider'] === 'twitter') { $profileurl = empty($identity['profileUrl']) ? '' : $identity['profileUrl']; $form['field_twitter_home_url'][LANGUAGE_NONE][0]['value']['#default_value'] = $profileurl; }
    Hope this helps.
  • That works for text fields, thank you. Can you make a suggestion in the case of a link field? If we have that, it should cover drupal's custom profile field application.
  • Hi,
    Not sure how related this is, but we now have a Rules integration, which is what you suggested apparently (thanks for that!).
    It is basic, as it exposes an event, with the social profile (text), that you can use to write rules. The event is triggered when a user registers with Oneall automatically (not via the register form).
    It is ready, but not yet distributed (in a few days, now on, but we can send over the module if you want.

    Anyway, could this help fill in a link field you mention?



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.