WordPress.org

Forums

Plugin won't save data in database (3 posts)

  1. Allen
    Member
    Posted 2 years ago #

    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?

  2. Jerry
    Member
    Posted 2 years ago #

    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

  3. Allen
    Member
    Posted 2 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic