Plugin Functionality Only for Editor and Administrator

You could check the user role when loading your metabox.

//get user
$user_id = get_current_user_id();
$user = new WP_User($user_id);
//check user role
if($user->roles[0] == 'administrator' || $user->roles[0] == 'editor') {
     //add your metabox here
}

That way the metabox is only added to the post for editor’s and users, you’ll probably want to wrap your save functionality in a similar condition so that it doesn’t try to run every time the post is saved.

EDIT: If you plan to use this on any other site or release it for others to use, I’d also recommend setting up an options page for your plug-in so that the user roles that are able to use this plug-in can be selected from a list of current user roles.

That way custom user roles can be accounted for, as well.

error code: 523