Display user role under BuddyPress username on profile page

URL: http://yourtechadvisors.com/members/yourtechadvisors/
I am using the following code in the file

<span class="user-role">
$user = new WP_User( bp_displayed_user_id() );
echo $user->roles[0];

I am wondering if there is a way to use this code with a function in functions.php so that when the plugin is updated, I don't have to keep coming back to change this file. If not, it will be fine, this ticket is more for looking towards convenience then fixing an issue.

Thanks, please let me know what the best solution would be here.