Title: [Plugin Developement &#8211; My 1st Plugin ] Plugin enable to save its data
Last modified: August 20, 2016

---

# [Plugin Developement – My 1st Plugin ] Plugin enable to save its data

 *  [Osama Shabrez](https://wordpress.org/support/users/osamashabrez/)
 * (@osamashabrez)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-developement-my-1st-plugin-plugin-enable-to-save-its-data/)
 * Hello All,
 * I am new to this forum and for the same reason I apologize if I have posted this
   topic in some other category then its own.
 * Currently I am developing my first plugin and created all the UI stuff. Now I
   am trying to save the plugin options user choose but it isn’t working.
 * I have registered the settings hook, settings group and options variable but 
   it still redirects the page to options.php
 * Here is a code snippet I have written to register the settings hook and the settings
   initialization:
 *     ```
       // Adding settings group and variable
       function MY_settings() {
       	register_setting('Mygroup','Mysettings');
       }
       // Registering settings hook
       add_action('admin_init','MY_settings');
       ```
   
 * Now to get the data from variable, I am using
 *     ```
       global $My_Settings
       <input name="Mysettings[id]" type="text" id="id" value="' . $My_Settings[id] . '" class="regular-text" />
       ```
   
 * And at the top of MyPlugin.php file, I have this code:
 *     ```
       $My_Settings = get_option('Mysettings');
       if( ! $My_Settings ) {
       	$My_Settings = array(
       		'id' => 'Enter you ID here'
       	);
       	update_option('Mysettings',$My_Settings);
       }
       ```
   
 * Any help will be really appreciated, and a small code snippet if you can provide
   will be great too. I know I am missing a very small check or something but I 
   am unable to figure it out.
 * Thanks,
    Osama

The topic ‘[Plugin Developement – My 1st Plugin ] Plugin enable to save its data’
is closed to new replies.

## Tags

 * [first plugin](https://wordpress.org/support/topic-tag/first-plugin/)

 * 0 replies
 * 1 participant
 * Last reply from: [Osama Shabrez](https://wordpress.org/support/users/osamashabrez/)
 * Last activity: [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-developement-my-1st-plugin-plugin-enable-to-save-its-data/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
