Difference between Option_Group and Option_Name in Register_Settings

I think the title pretty much says it all! I’m working my way through various tutorials on how to add an options page to my test plugin and am struggling to understand the Register_Settings function.

Every tutorial I have found quotes the codex for the arguments then uses the same text in the Option_Group and Option_Name argument. Can someone explain it to me please?

Related posts

Leave a Reply

1 comment

  1. The codex defines the function as:

    register_setting( $option_group, $option_name, $option_validate_function );
    
    • $option_group is settings group name. Use when displaying on a settings page for example
    • $option_name is the database entry name
    • $option_validate_function is the callback for this database entry/this option.

    Most codex tutorials use an array of data in one $option_name but that’s not required (just more efficient in terms of table rows). You can add multiple options with unique names under the same option group.

    Usage

    • $option_name is the name you access when using get_option( $option_name ).
    • $option_group is the group name used when creating security with settings_fields( $option_group ).