Plugin options will not save in database

I’m not sure what’s happening here, since this has worked in another plugin I’ve created. I’m simply trying to store data in the options table.
Here is the code I’m using:

function on_myplugin_start () {         
register_setting('first_tab_options', 'first_tab_items');
}

add_action('admin_init','on_myplugin_start');

Here is the form that gets submitted:

<form action="options.php" method="post" >
<?php
 settings_fields( 'first_tab_options' );
 ?>
<input type="text" name="some_name" value="">
<input type="submit" value="Save Settings" name="submit" class="button-primary">
</form>

That’s it..when I look at the source code, everything looks fine…there is all the hidden fields put in by the settings API..but when I put in a value and hit submit (and it says successfully saved, nothing is in the database field that was successfully created (first_tab_items).

I would appreciate any help on this….thanks

2 s
2

…because your input (POST) name needs to match the one in your register_setting call:

register_setting( 'first_tab_options', 'first_tab_items' );
....
<input type="text" name="first_tab_items"...

Otherwise how the hell does WP know that some_name in POST holds your option data? 😉

Leave a Comment