I'm trying to be a good thememaker and pass all my settings through the Settings API, but I'm running into some difficulty in the sanitization callback function.

The core of the problem is this: the $input variable, passed in by default, is empty. My $_POST[options group] is coming through just fine (it has everything I'd expect to see in $input) but, again, $input is empty. Where do I even start looking to debug this?


In response to Chip, here's what I have (stubbed, obviously):

function lblg_sanitize_options( $input ){
global $lblg_shortname, $lblg_default_options;

echo "Input: ";

If I do something similar using, e.g., Oenology and do a print_r($input);, I get the expected Array( etc.


Here's the results of print_r($_REQUEST); for my theme:

Array ( [option_page] => lblg_options [action] => update [_wpnonce] => 1f96eb2410 [_wp_http_referer] => /wp-admin/themes.php?page=lblg_options [lblg_options] => Array ( [layout_stylesheet] => Select a layout: [alt_stylesheet] => *none* [use_custom_header] => true [display_footer_copyright] => true [footer_copyright] => [footer_credit_text] => [save] => Save changes ) )

And here it is for Oenology:

Array ( [option_page] => theme_oenology_options [action] => update [_wpnonce] => 748c46a1a1 [_wp_http_referer] => /wp-admin/themes.php?page=oenology-settings [theme_oenology_options] => Array ( [header_nav_menu_position] => below [header_nav_menu_depth] => 1 [display_social_icons] => on [rss_feed] => rss2 [facebook_profile] => [flickr_profile] => [linkedin_profile] => [myspace_profile] => [twitter_profile] => [youtube_profile] => [display_footer_credit] => false [submit-general] => Save Settings ) )

I can't spot the difference. Can you?


Might the various slugs/shortnames/pagenames be conflicting somehow?


Here's what I'm doing for registration:

function lblg_admin_init(){
    global $lblg_shortname;
    register_setting( 'lblg_options', $lblg_shortname . '_lblg_options', 'lblg_sanitize_options' );

Here's what I'm calling out, intra-options-form:

settings_fields( 'lblg_options' ); 
do_settings_sections( 'lblg_options' );

The settings themselves are all being registered in a big loop, in a fashion similar to this:

add_settings_field( $key, $value['name'], '', 'lblg_options', $section );

Further thoughts?


2 Answers 2


The $input variable is not passed to the validate function by default. You need to declare it, e.g. not this:

function mytheme_validate_settings() {}

But rather, this:

function mytheme_validate_settings( $input ) {}

(Or maybe I'm the only one who's made that bone-headed mistake before?) :)


The other thing to check: does the $optiongroup in register_setting() match the argument passed to settings_fields() in your form markup?

  • No, I've got that. I'm actually taking a page from your Oenology setup, it's just not working.
    – ZaMoose
    Commented May 12, 2011 at 13:29
  • Next thing to check: $optiongroup. See edit. Commented May 12, 2011 at 13:42
  • Check the edits above.
    – ZaMoose
    Commented May 12, 2011 at 15:35
  • Where is the $optiongroup passed into add_settings_field()?
    – Felix Eve
    Commented May 15, 2014 at 10:29
  • Arr, I see, it has to match the variable passed into settings_fields(), not add_settings_field().
    – Felix Eve
    Commented May 15, 2014 at 20:46

Answering my own question by way of an answer Chip has embedded in his excellent settings tutorial, namely: it's all about Correlating Function Arguments. Apparently some of the variable names/options group names I was using weren't lining up correctly.

  • That's the trickiest part sometimes, isn't it? Commented May 20, 2011 at 23:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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