Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

...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? ;)

share|improve this answer
    
exactly. Plus, you should use a safer way to register your options. Use namespaces. A good way to learn is to use this boilerplate: themergency.com/generators/wordpress-plugin-boilerplate –  pixeline Aug 11 '12 at 22:44
add comment

Your Answer

 
discard

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.