Twitter user specific meta tags in Drupal pages

When it comes to Twitter integration, you are likely to hit the corresponding module. While the module is actually fine and handily integrates a lot of Twitter’s API functions as well as OAuth 2.0 login to your Drupal site, it lacks well-thought support for a few important standard Drupal APIs, such as token or fields.

However, on hook_user_load, it adds its user specific details to the $account object, which makes them exploitable at site-building level. Here’s what I did to make a user-blog entry node page contain both a twitter:creator and a twitter:creator:id metatag, set to the post author’s actual Twitter account details. And only in case he provided one.

Meta tags quick and Rules to the rescue

Meta tag module is no option, because Twitter module lacks token support. Lucky that Valery Lourie has contributed Meta tags quick module.

Once the base module is enabled, rules will offer an additional action named Add meta tag at page level (and below). At this point, you can happily modify whatever Twitter account detail you want to have added as a meta tag, by loading the account object (if necessary) and checking for its twitter_accounts property, an Array of Twitter objects providing a lot of details.
Needless to say that you may want to consider publishing these details twice, in respect of your very own users’ privacy. After all they have shared their account details with you.