is_admin() is a call that does not verify if the current user role, but rather it was made to check if the code is trying to display in the backend/admin/dashboard area.
https://codex.wordpress.org/Function_Reference/is_admin
You can try one of three solutions:
-
Reverse the check
if(is_admin()) // if display on the dashboard, abort return; ..... your code
-
Check for the user capabilities with the current user check and if the dashboard/admin is being displayed:
if(!current_user_can('manage_options') && is_admin()) { Your code }
-
Check the actual roles and by default, therefore not display the admin:
function is_this_admin_user() { return in_array('administrator', wp_get_current_user()->roles); } if(is_this_admin_user() == 0) { ....your code }