How to save Setting pages data to the database?
I have created a setting page and I have a basic form in there I want to save its data in the database how can I achieve that. This is the HTML form:
label class=?php _e('Message', 'domain'); ? /label
textarea class=message form-control name=my_settings_fields[message]?php echo esc_html($my_setting_data[ 'message' ]); ?/textarea
This is how I registered my setting page:
public function my_register_settings()
{
register_setting('my_setting_option_page', 'my_settings_fields', 'sd_callback_function');
}
/**
* Register the plugin settings page.
*
* @since 1.0.0
*/
public function my_register_menu_page()
{
add_submenu_page(
'edit.php?post_type=post',
__('FAQPress Settings', 'domain'),
__('Settings', 'domain'),
'manage_options', 'my_settings',
array($this, 'my_add_setting_page'));
}
/**
* Callback for plugin setting page registration.
*
* @since 1.0.0
*/
public function my_add_setting_page()
{
require plugin_dir_path(__FILE__) . 'partials/my-admin-settings.php';
}
Topic settings-api plugin-development options html plugins Wordpress
Category Web