Took me a little while to work out, but here's how to do it. Add this to your template_preprocess_node function in your template. If anyone has a better or faster way of doing please do let me know. At the moment I am loading in the entire term just to get the name and url.
// We load in the term of node author
$nodeprofile = profile2_load_by_user($variables['uid']);
//Change field name here to be the name of your field. In this example we load in the URL and term name.
$termer = taxonomy_term_load($nodeprofile['main']->field_member_associate['und'][0]['tid']);
// Put the author string together.
$variables['author'] = t('Posted by !username from !org', array('!username' => $variables['name'],'!org' => l(t($termer->name), 'taxonomy/term/' . $termer->tid)));
Then in your theme print the whole thing out with:
print $author;
At the moment I get a ton of notice warnings, but it works.
Comments
Comment #1
joachim commentedInteresting example, thanks for sharing it! Though I don't really understand what you're doing with taxonomy here -- how does that relate to users?
Comment #2
cnolle commentedI've set my users up to be grouped using profile2 and taxonomy. Probably not the best way or creating groups of users - but seems to work without adding the complexity of organic groups.
Comment #3
faqing commentedPlease see here:
http://drupal.org/node/1300460
Comment #4
faqing commentedPlease see here:
http://drupal.org/node/1300460#comment-6470486