Hi, I am working on a new plugin for CC and was wondering if there is a better system for determining current user role? I was a little surprised that there is no function in WP that would return string with user role (I know roles are deprecated in favor of current_user_can - capablities), so I was wondering if I am doing things the right way, or there is some better way to do this.
if (is_user_logged_in()){ if (!current_user_can('delete_posts')){ $user_role = 'Subscriber'; } else if (!current_user_can('delete_published_posts')){ $uset_role = 'Contributor'; } else if (!current_user_can('read_private_pages')){ $user_role = 'Author'; } else if (!current_user_can('edit_dashboard')){ $user_role = 'Editor'; } else if (!current_user_can('manage_network')){ $user_role = 'Administrator'; } else { $user_role = 'Super Admin'; } } else { $user_role = 'Anonymous'; }