How to create a user object of a custom form and add a user in drupal 7? i am new to drupal ,basically wanted to create a user object for my custom form and add a user. 

This is my custom form 

function registerme_newform($form, &amp;$form_state) 
{
$form = array();
$form['account details'] = array(
    '#type' =&gt; 'fieldset',
    '#title' =&gt; t('Account Details'),
    '#description' =&gt; t('Enter Personal Credentials'),
    );
$form['account details']['first name'] = array(
    '#type' =&gt; 'textfield',
    '#title' =&gt; t('First Name'),
    '#default_value' =&gt; t('Be sure of your first name'),
    '#attributes' =&gt; array(
    'onblur' =&gt; "if (this.value == '') {this.value = 'Be sure of your first name'}",
    'onfocus' =&gt; "if (this.value == 'Be sure of your first name') {this.value = ''}" 
      , ), 
       ); 
     $form['account details']['last name'] = array(
    '#type' =&gt; 'textfield',
    '#title' =&gt; t('Last Name'),
    '#default_value' =&gt; t('Be sure of your last name'),
    '#attributes' =&gt; array(
    'onblur' =&gt; "if (this.value == '') {this.value = 'Be sure of your last name'}",
    'onfocus' =&gt; "if (this.value == 'Be sure of your last name') {this.value = ''}" 
       , ), );

     $form['account details']['email'] = array(
    '#type' =&gt; 'textfield',
    '#title' =&gt; t('E-Mail'),
    '#required' =&gt; TRUE,
    '#default_value' =&gt; t('Email acts as username.Dont forget it!'),
    '#attributes' =&gt; array(
    'onblur' =&gt; "if (this.value == '') {this.value = 'Email acts as username.Dont forget 
     it!'}",
    'onfocus' =&gt; "if (this.value == 'Email acts as username.Dont forget it!')
 {this.value = ''}" 
       , ), 
    );

    $form['account details']['password'] = array(
    '#type' =&gt; 'password',
    '#title' =&gt; t('Password'),
    '#maxlength' =&gt; 60,
    '#size' =&gt; 60,
    '#required' =&gt; TRUE,
    '#description' =&gt; t('Password should be atleast 6 characters long.'),
    );

$form['home'] = array(
    '#type' =&gt; 'fieldset',
    '#title' =&gt; 'Home Address',
    '#description' =&gt; t('Enter Personal Residential Credentials')
);

$form['home']['street'] = array(
    '#type' =&gt; 'textfield',
    '#title' =&gt; 'Street Address',
);

 $form['home']['city'] = array(
    '#type' =&gt; 'textfield',
    '#title' =&gt; 'City',
);

 $form['work'] = array(
    '#type' =&gt; 'fieldset',
    '#title' =&gt; 'Work Address',
     '#description' =&gt; t('Enter Official Address')
);

$form['work']['street'] = array(
    '#type' =&gt; 'textfield',
    '#title' =&gt; 'Street Address',
);

 $form['work']['city'] = array(
    '#type' =&gt; 'textfield',
    '#title' =&gt; 'City',
);

 $form['submit'] = array(
     '#type' =&gt; 'submit',
     '#value' =&gt; t('Register Me'),
);

 return $form;

}

function registerme_newform_validate(&amp;$form, &amp;$form_state)
{
if($form_state['values']['account details']['first name']=='Be sure of your first name')
{
form_set_error('first name',t('Please enter your first name'));
}
}
function registerme_newform_submit(&amp;$form, &amp;$form_state)
{
dsm($form_state);
}


Is user_save method for creating an object? How to implement this please guide or suggest otherwise. Thanks
You can save the details of the user in an array and can use "user_save" function to create new user.
You can get the values from the $form_state elements

    $details = array(
      'name' =&gt; '',
      'pass' =&gt; user_password(),
      'mail' =&gt; '',
      'init' =&gt; '',
      'status' =&gt; 1,
      'access' =&gt; REQUEST_TIME,
      'field_fname' =&gt; '',
      'field_lname' =&gt; '',
    );
    user_save(drupal_anonymous_user(), $details );


drupal_anonymous_user() will generate the default anonymous $user object.