How do you retrieve a $_POST in inside the options page? I'm currently trying to save some $_POST variables I got from the options page, and save it inside my custom table for the WordPress plugin. However, it won't save.
Here's the code
public static function save_poll(){
$plugin_id = ID;
global $_POST;
if($_POST)
if($_POST[$plugin_id."_action_taken"])
self::add_poll($_POST[$plugin_id."_category"], $_POST[$plugin_id."_politician"], $question);
}
public static function add_poll($cat_id, $politician_id, $question, $answers = ""){
global $wpdb;
$wpdb->insert(
a14_POLL_QUESTIONS,
array(
'category_id' => $ca_id,
'tag_id' => $politician_id,
'question' => $question
));
return $wpdb->insert_id;
}
I also tried hooking it up to the 'admin_init' though it still won't budge.. I was trying to look at the internet for hours yet, to no avail. Is there any special way that we could access some $_POST variables?
I am truly sure that these variables wont be registered since I used a unuique ID for it.
$plugin_id = IDdoesn't compute, well this one neither:global $_POST(at least, never seen it...). Please, post a workable code. Only this excerpts don't show the full picture. You are free to edit your Question whenever needed. – brasofilo Feb 15 at 8:16$_POSTis a superglobal so you never have to redeclare it, and it is always there so don't bother to test for it. (Also: use isset() to test whether a variable exists in scope, as it won't raise an error when testing an undeclared variable) – webaware Feb 15 at 10:14