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

I'm generating this form using Settings API:

<form action="options.php" method="post">   
   <?php settings_fields('XX_theme_settings'); do_settings_sections('my_settings'); ?>
   <input type="hidden" name="foo" value="bar" />
   <input name="SubmitButton" type="submit" class="button-primary" value="<?php _e('Save Changes'); ?>" />   

Validation callbacks $input array returns only 'my_settings' input fields.

How do I access foo (bar) input's value and submit button's name SubmitButton?

This doesn't work for the hidden input:

my_validation($input) {
   $foo = $input['foo'];

And when it comes to the submit button I don't even know where to start.

share|improve this question
and $foo = $_POST['foo']? I don't use settings API too often, just a guess. – ungestaltbar Mar 2 '12 at 23:18
Christ, I was trying to do everything within Settings API and didn't even tried $_POST array. Of course you were right, it works! Please repost your comment as an answer so I will be able to accept it. Thank you! :) – Wordpressor Mar 3 '12 at 0:10
up vote 4 down vote accepted

Using $_POST is too low level. Simply give it the same name as your other options. When you options are displayed they should have the names of the form: my_settings[a_particular_option]. For instance:

<input name="my_settings[some_input_option]"/>

Then for your hidden input and submit button:

<input type="hiddden" name="my_settings[foo]" value="bar"/>
<input name="my_settings[SubmitButton]" type="submit" class="button-primary" value="<?php _e('Save Changes'); ?>"/>

In your validation array

my_validation($input) {
   $foo = $input['foo'];
   $submit = $input['SubmitButton'];
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.