Support » Plugins and Hacks » Hacks » Plugin won't save data in database

  • I’ve been trying to figure out why this isn’t working and could use some help. I’m updating a plugin I wrote and will now be using a tabbed interface for the various options. On the first tabbed interface, the data gets saved just fine, but it doesn’t for the second tab…here is the essence of what is being used for this:

    function on_myplugin_start () {
    register_setting(‘first_tab_options’, ‘first_tab_items’);
    register_setting(‘second_tab_options’, ‘second_tab_items’);
    }

    add_action(‘admin_init’,’on_myplugin_start’);

    then when I have 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>

    Now, I do exactly the same for the second tab, and it looks like this:

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

    but this doesn’t save anything in the database (the field second_tab_items gets created in the database but is empty)

    Is there something I’m missing?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Haha a done this a million tomes myself. Your input names must match those of the register settings calls.

    Ie ‘some_name’ should be first_tab_items

    Hi Jerry…thanks…yes, something I always forget…will finally (hopefully) get this idea now.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Plugin won't save data in database’ is closed to new replies.