You can use the WP_User
class and the has_cap($role)
method. The show_user_profile
action passes a WP_User
object as a parameter to the called function.
http://codex.wordpress.org/Class_Reference/WP_User#has_cap.28.24cap.29
add_action('show_user_profile', 'my_add_extra_profile_fields');
function my_add_extra_profile_fields($user) {
if ($user->has_cap('subscriber'))
{
//Code here
}
}