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
…because your input (POST) name needs to match the one in your
register_setting
call:Otherwise how the hell does WP know that
some_name
in POST holds your option data? 😉Adding to TheDeadMedic’s answer: if you want to register just one setting for an entire form like you implied, you can use an array:
And register: