How do I get the roles of the currently logged-in user? In Drupal 8 I would use the following code.
$current_user = \Drupal::currentUser();
$roles = $current_user-&gt;getRoles();

What is the equivalent code I should use in Drupal 7?
You can access the current user in D7 via the global $user object
global $user;
$roles = $user-&gt;roles;