Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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 ).
share|improve this answer
1  
Ok, so if I understand you correctly each Option_Name is a new line in the database, and they are held together by the Option_Group. But given that all of the tutorials use an array to store their data (and I understand the benefits of that) the two variables can be the same without any side effects. I really appreciate your help with this - its been bugging me for a few days! –  Jamie Wright Jan 15 '13 at 22:21
1  
Yes, yes and yes. That's the reason why tutorials use the SAME identifier for name as for group. The thing is, you don't NEED to. You may always register multiple name for a single group. Can be convenient if you have optional modules with separate save code. Saving might overwrite options already there. So you register a new option. But displaying them should happen at the same options page, so you tie it to the same group and voila. –  Derk-Jan Jan 16 '13 at 0:21
    
Thanks for your help. –  Jamie Wright Feb 4 '13 at 11:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.