I need to add on condition to profile form submit handler profile2_form_submit_handler I need to add on condition to profile form submit handler. I have wrote the condition to profile2_form_submit_handler function which is found under sites/all/modules/profile2/profile2.module location.
I have applied the condition in core file but now wanted to move this set of core to template.php file but it is not reflating.
Anyone please suggest me to make it from hook or something other. 
My code is:

function THEMENAME_form_submit_handler(&amp;$form, &amp;$form_state) {
  profile2_form_submit_build_profile($form, $form_state);
  // This is needed as some submit callbacks like user_register_submit() rely on
  // clean form values.
  profile2_form_submit_cleanup($form, $form_state);

  foreach ($form_state['profiles'] as $type =&gt; $profile) {
    // During registration set the uid field of the newly created user.
    if (empty($profile-&gt;uid) &amp;&amp; isset($form_state['user']-&gt;uid)) {
      $profile-&gt;uid = $form_state['user']-&gt;uid;
    }

    // check default image status
    // if there is not any then make first image as default 
    $default = false;
    $images = $profile-&gt;field_user_image['und'];

    foreach($images as $image) {
        if(($image['field_profile_default']['und'][0]['value'] == 1)
         &amp;&amp;($image['entity']-&gt;field_profile_default['und'][0]['value'] == 1)) {
            $default = true;
            break;
        }
    }

    profile2_save($profile);
  }
}
A theme can not simply override a form handler. What you need is a form alter function (hook_form_FROM_ID_alter()) to alter the profile2 form, remove its original submit handler and replace it with your own.

THEMENAME_form_profile2_form_alter(&amp;$form, &amp;$form_state) {
  array_splice($form['#submit'], array_search('profile2_form_submit_handler', $form['#submit']), 1, 'THEMENAME_form_submit_handler');
}


Because your are changing the behavior of your site, this should be implemented in a custom module rather than in the theme. Themes are about presentation.

Also, instead of altering profiles on form submit, you could also implement hook_profile2_presave() to alter the profiles before they are saved to the database, regardless on how they are created (ie. your code will also work for profile created programmatically).