Question

say i have an option

update_option('pp_options', $options);

when i want to create a form for that, i learnt that i have to create a settings group

register_setting('pp_options_group', 'pp_options');

then in the form do

settings_fields('pp_options_group')

but i dont really what is the settings group actually for? i know its to do with sanitization but why the need to create a group for sanitization?

Was it helpful?

Solution

Sanitization is secondary function. Main is:

The register_setting and unregister_setting functions add and remove options from a whitelist of allowed options that the form is able to save. They can also name a sanitize callback function as a security measure to check each option's value. ( Register settings )

Technically $option_group argument is used for:

  • array key in global array of whitelisted options
  • part of filter name to run sanitization callback
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top