I have a custom field on my user profile pages where users can enter their Twitter user name. When the user's profile is rendered (either on the user profile page itself or via views) I would like to rewrite this field so that it links to the user's twitter profile following the pattern http://twitter.com/[field_twitter_name].

I discovered the twitter username project on DO yesterday (https://drupal.org/project/twitter_username) and this would help me accomplish the objective, especially for new users. However, we currently have ~900 active users on our site.

Is there a way to create a new field and update its tables with the existing user's twitter names? Or is there a way to change the field type from it's current setting of "Text field" to the new type made available by the twitter username project "Twitter username"?

Any help would be greatly appreciated.

1 Answer 1


You could write a small one-off DB copy function to accomplish the task. There a couple of modules around but they appear to be quite old, so it would depend on what version you run. Here's a tutorial for MySql (if that's what you use) DB access: http://www.w3schools.com/php/php_mysql_intro.asp

  • Thanks, Geoff. I was able to insert the data from the existing field table (field_data_field_twitter_name) into the new table (field_data_field_new_twitter_field) on my local machine to test this out for 10 records. The data imported successfully however, the data that was imported does not show up in the field on the user's profile. Is it possible that the twitter_username module is pulling data from another field as well? And if so, how could I figure out what other table(s) I need to update? Commented Jun 1, 2014 at 15:08
  • Also, just to confirm that the field itself works properly, I tested out inserting records into that field via the standard UI (editing the user profile page at localhost/sitename/user/%/edit and those records render properly as links to twitter.com/user on the user profile page and elsewhere via views. Commented Jun 1, 2014 at 15:11
  • according to the INSTALL file, it only affects one field - I would check phpMyAdmin to make sure that the format of the known good entry matches the copies - there could be a simple mismatch from copying the data
    – Geoff
    Commented Jun 1, 2014 at 15:34
  • Thanks again, Geoff. Turns out that the data imported fine but that I had to update both the field_data_field_new_twitter_field table and also the field_revision_field_new_twiiter_field table before it would work. Commented Jun 1, 2014 at 17:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.