Using the WordPress Customizer for Saving User-Specific Options
read more
Categories

Using the WordPress Customizer for Saving User-Specific Options


The WordPress Customizer — which started out as the theme customizer — is currently one of the best options to allow end-users to customize a theme or plugin. The Customizer is rapidly expanding in its feature set, with the new panels in WordPress 4.0 and the work on a complete JavaScript API for the Customizer giving it a better overall UX and making it more useful.

Just as the Customizer doesn’t have to be limited to admin use only, it turns out that it doesn’t have to be limited in the use of setting options either. By default, the Customizer stores in theme mods — the special set of options for the current theme. It can also save to any other option.

In this article I’ll show you how to store the option in a different way, for example user meta. Once you understand how this works, you should be able to use the Customizer with any type of data storage. In fact, since we will be using a action hook, you will be able to use values set to cause any code to run.