Why won’t register_setting() create a setting?

I am not exactly sure what you mean by saying that you can see your settings section and fields displayed correctly, but your my_plugin_settings has not been created.

I know sometimes I forget to add the actual admin part in which generally looks something like this:

settings_fields( 'my_plugin_settings' );
do_settings_sections( 'my_plugin_settings' );

submit_button();

Or is that you are having trouble when saving the form? If that’s the case then I would need to see your callback function.

Sorry if this is not accurate to what you need, but I can;t currently comment on your question to clarify more before posting an answer. If this does not answer then let me know and I will adjust my answer accordingly.

EDIT #1:

I will be honest and say I am not 100% sure that the settings will automatically be added to the database. What I do right before adding the settings section and settings field is this.

/* If the options do not exist then create them*/
if ( false == get_option( 'my_plugin_settings' ) ) {
    add_option( 'my_plugin_settings' );
}

This will create the option in your database.

Leave a Comment