public function save() { $grants = new \WordPress\Tabulate\DB\Grants(); // Validate the POSTed grants. $new_grants = array(); foreach ($_POST as $table => $table_grants) { if (in_array($table, $this->table_names)) { $new_grants[$table] = array(); foreach ($table_grants as $capability => $roles) { if (in_array($capability, $grants->get_capabilities())) { $new_grants[$table][$capability] = array_keys($roles); } } } } // Save the grants and return to the granting table. $grants->set($new_grants); $this->template->add_notice('updated', 'Grants saved.'); wp_redirect($this->get_url('index')); exit; }