// For each role object
foreach ($roleObjects as $key => $role) {
-//if ( isset($role->capabilities[$capability])) {
-//$role->remove_cap($capability);
-//}
-
- // Check if the role exists in list of editable roles and capability
- // does not exist
+ // Check if the role exists in list of editable roles and
+ // the capability does not exist
if (isset($roles[$key]) && ! isset($role->capabilities[$capability])) {
- // Check for default value
+ // Check if a default value has been specified in the $default array
$enabled = false;
- if (isset($default[$role['name']])) {
- $enabled = $default[$role['name']];
+ if (isset($default[$role->name])) {
+
+ // It has, so use that
+ $enabled = $default[$role->name];
+
}
// Add the role
$role->add_cap($capability, $enabled);
+
}
}
}