Creating default user settings on plugin initialization
A typical first step of most user-configurable plugins is to create a default set of values for all options when the plugin is activated. These default options will subsequently be used to populate the plugin's configuration page when it is visited by the site administrator.
How to do it...
Follow these steps to register a function that is called when a plugin is activated and learn how to store options data in the site database:
- Navigate to the WordPress
pluginsdirectory of your development installation.
- Create a new directory called
- Navigate to this directory and create a new text file called
- Open the new file in a code editor and add an appropriate header at the top of the plugin file, naming the plugin
Chapter 3 - Individual Options.
- Add the following line of code to register a function that will be executed when the plugin is activated...