0

I am trying to add my own plugin option to the Easy digital downloads plugin. The sample code is here:

http://docs.easydigitaldownloads.com/article/383-automatic-upgrades-for-wordpress-plugins

I have added another register setting in the register_option

  register_setting('owlish_settings_group','owlish_display_notes');

And in the form I get the option

$displaynotes = get_option( 'owlish_display_notes' );

and I have there two settings_fields callings

<?php settings_fields('owlish_license'); ?>
<?php settings_fields('owlish_settings_group'); ?>

And in the form I have the checkbox above the submit button

  <table class="form-table">
  <tr>
    <th scope="row"><?php _e('Show notes?', 'owlish-textdomain'); ?></th>
    <td id="front-static-pages">
    <fieldset>
    <legend class="screen-reader-text"><span><?php _e('Show notes?', 'owlish-textdomain'); ?></span></legend>
    <ul>
    <li><input type="checkbox" name="owlish_display_notes" value="1" id="owlish_display_notes" <?php checked('1'==$displaynotes); ?> /><label for="show_notes"> <?php _e('show notes', 'owlish-textdomain'); ?></label></li>
    </ul>
    </fieldset>
    </td>
  </tr>
  </table> 

This is all I added to the EDD sample code. The problem is, I can only save one of those options. If I have the both settings_fields calls active, only the owlish_display_notes are saved. If I comment the settings_fields('owlish_settings_group'); out, then the license is saved, but not the notes.

This is driving me nuts. I am ok with the settings saved in each table row in the options for now, it just should work.

What am I missing here? Thanks so much

1

take a look at https://tommcfarlin.com/multiple-sections-on-wordpress-options-pages/

You can...

add_settings_section("owlish_license", "SECTION NAME", null, "theme-options");
add_settings_section("owlish_settings_group", "SECTION NAME 2", null, "theme-options");

add_settings_field("owlish_display_notes", "Display Notes", "callback1", "theme-options", "owlish_license");
register_setting('owlish_settings_all','owlish_display_notes');

add_settings_field("owlish_display_notes2", "Display Notes 2", "callback2", "theme-options", "owlish_settings_group");
register_setting('owlish_settings_all','owlish_display_notes2');

after you can use this wrapper on page

settings_fields("owlish_settings_all");
do_settings_sections("theme-options");

Have a nice day.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.