Nov 07

In this post I will explain how I use the WordPress database (MySQL) for the DiveBook plugin I am currently developing. For my plugin I am using the options table in WordPress for storing options and settings for my plugin. The DiveBook plugin will be storing information about dives and for this I am creating new tables in the WordPress database.

In my previous post “Getting started with WordPress plugin development” I talked about how to create a widget for the plugin and how to save options for the widget in the control panel. In the widget.php file I used the option table to store and retrieve the data.

The following code will store data to the options table when the user submits the options.

        //Store title and numdives in options table
        if ($_POST['divebook-submit']) {
            $options['title'] = strip_tags(stripslashes($_POST['divebook-title']));
            $options['numdives'] = strip_tags(stripslashes($_POST['divebook-numdives']));
            update_option('divebook', $options);

Continue reading »

Tagged with:
Subscribe to my feeds Follow me on Twitter