Support » Plugins » Grab $_POST Variables By Key In save_post action.

  • https://gist.github.com/732629

    I have posted the plugin which uses a custom post type of ‘did_you_know’. It is incredibly trimmed to demonstrate this issue. Essentially I cannot grab a value by key from $_POST[‘key’] but can print_r($_POST); and see it in there. I can also foreach to get the value. This is very strange behavior.

    Any help is greatly appreciated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • My first thought was that maybe the key has an invisible character in it. What happens if you do something like var_dump(isset($_POST['did_you_know']))? You should get true.

    Returns false however, var_dump($_POST) show it exists. What the heck is happening here!?

    Try doing something like this:

    print "<pre>\n";
    foreach($_POST as $k => $v) {
        print "[$k]: [$v]\n";
        print "\t" . $_POST[$k] . "\n";
    }

    Obviously the first print should show the key and value, and the second print should show the value again, but this time via indexing the array. If this loop works without blowing up then there’s something about that key that is non-obvious. I would still put my money on some invisible character.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Grab $_POST Variables By Key In save_post action.’ is closed to new replies.