WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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;
            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;
        '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.

share|improve this question

closed as too localized by toscho Mar 15 '13 at 22:01

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

This $plugin_id = ID doesn'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 '13 at 8:16
Also, please read how to deal with Multi-posting: stackoverflow.com/q/14888496 – brasofilo Feb 15 '13 at 8:23
+1 per brasofilo, + $_POST is 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 '13 at 10:14
And don't forget to use the third argument, as you might want to prepare the values before inserting it into the DB. Also you should validate and sanitize your data. – kaiser Feb 15 '13 at 11:20