Last active
December 31, 2015 16:39
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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