Create a menu item whenever a taxonomy term is created

function your-module-name_taxonomy_term_insert($term) {
$menu_item = array(
'link_title' => $term->name,
'menu_name' => 'your-menu-machine-name', // It uses '-', not '_'
'customized' => 1, // Must be 1 in order to not dispaly the link in any language
'link_path' => 'taxonomy/term/' . $term->tid, // menu_link_save() does not like aliases. Then 'nid' is used
'language' => 'en', // language is required in order to make the item translatable
'plid' => $plid, // id of the sub-menu if you want to add this in sub-menu
'weight' => '-50',
$mlid = menu_link_save($menu_item); // You don't need to receive it in a variable
$ml = menu_link_load($mlid); // I'm loading $mlid just to display the result and verify it

Add a extra submit handler to the hook_form_alter

In my case i have to add a twitter account to the user profile, but by default it comes in a tab. So i have to add a field( for twitter handler) in the user profile so that on submit that twitter handler can be added to the user profile.
i created a custom function for submitting the form, this is mainly a overriding the default submit handler by just changing the function name.

function twitter_account_form_submit_custom($form, &$form_state) {
module_load_include('lib.php', 'twitter','twitter');
module_load_include('inc', 'twitter','twitter');
$name = ($form_state['profiles']['main']->field_twitter_handle['und'][0]['value']);
$twitter = new Twitter($name);
try {
$account = $twitter->users_show($name, FALSE);
} catch (TwitterException $e) {
form_set_error('screen_name', t('Request failed: @message.', array('@message' => $e->getMessage())));
$uid= $form_state['values']['uid'];
$result = db_select('twitter_account' , 't')
->condition('uid',$uid, '=')
->condition('uid', $uid, '=')
twitter_account_save($account, TRUE, user_load($form_state['values']['uid']));

Now i have to add submit handler to the hook_form_alter. i just need to add a extra submit handler the $form[#sumit][]= ‘ ‘; .

function hook_form_alter {
if($form_id == 'user_profile_form')
$form['#submit'][] = 'ekn_user_profile_form_submit';
$form['#submit'][] = 'twitter_account_form_submit_custom';