Adding Settings Fields to Your WordPress Plugin

When developing a plugin for WordPress, a lot of times you’ll want to create your own page of options within the administration area. To do so, you’ll usually use the add_options_page() or add_submenu_page() function to actually create the page; but then you’ll have to populate that page with the actual settings fields.

The first step in that process is to understand the add_settings_field() function. This function accepts 6 different parameters. They are as follows:

My First Contribution to WordPress

While it’s not an official contribution to WordPress, I did discover and fix an issue within a plugin I installed earlier today on my WordPress MU 2.7 installation. Apparently, WordPress MU 2.7 introduced the concept of registering and “whitelisting” any options that can be set for your plugin within the administration center. From the documentation on the WordPress Codex, this is something that will be coming soon in WordPress itself.

Anyway, I installed a plugin called “Events Manager” this morning and proceeded to attempt to edit the options for the plugin. I got everything the way I wanted it and pressed the “Save” button, only to be confronted with an error that said something along the lines of “Error! Options page not found.” Frustrated, I started to Google the issue and found very little help.