Skip to content

Instantly share code, notes, and snippets.

@liliakai
Last active December 31, 2015 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liliakai/8015485 to your computer and use it in GitHub Desktop.
Save liliakai/8015485 to your computer and use it in GitHub Desktop.
Return a list of (blog post) node authors, as user objects sorted by last name.
function cmp_user_last_name($user1, $user2) {
return strcmp($user1->field_user_last_name, $user2->field_user_last_name);
}
function sorted_authors($nid) {
// get the author uids from the content node
$node = node_load($nid);
$authors = reset($node->field_authors);
global $user;
$authors = array_map(user_load, $authors);
usort($authors, cmp_user_last_name);
return $authors;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment