get_names(); $dp_roles = get_option('duplicate_post_roles'); if ( $dp_roles == "" ) $dp_roles = array(); foreach ($roles as $name => $display_name){ $role = get_role($name); /* If the role doesn't have the capability and it was selected, add it. */ if ( !$role->has_cap( 'copy_posts' ) && in_array($name, $dp_roles) ) $role->add_cap( 'copy_posts' ); /* If the role has the capability and it wasn't selected, remove it. */ elseif ( $role->has_cap( 'copy_posts' ) && !in_array($name, $dp_roles) ) $role->remove_cap( 'copy_posts' ); } } ?>