Please guys , I tried a lot ro find out what’s the main purpose of this function , but i didn’t find what i want , i looked in the codex but seriously the description is not clear , i tried to see examples but finnally i saw an example i didn’t understand nothing from it .
<?php
echo '<form method="post" action="options.php">';
settings_fields( 'my-plugin-settings-group' );
?>
Via the Developer Reference (not the Codex)
Output nonce, action, and option_page fields for a settings page.
Here’s the source code for it
function settings_fields($option_group) {
echo "<input type="hidden" name="option_page" value="" . esc_attr($option_group) . "" />";
echo '<input type="hidden" name="action" value="update" />';
wp_nonce_field("$option_group-options");
}
so, it gives the form processor some info to work with for the current options page, and verification with nonce on submit.
UPDATE
It’s role is made more clear in the Settings API docs:
To display the hidden fields and handle security of your options form, the Settings API provides the settings_fields() function.
settings_fields( $option_group );