Add location to to profile2 just after the user registers I am trying to force add a location to a user's profile2 just after the user register's an account. The user's are able to add locations to their profile by using flags, but since there are no locations just after the user registers, the rules add fails because the locations list has not been initiated.

The below code is what I currently have:

if (isset($account-&gt;is_new) &amp;&amp; !empty($account-&gt;is_new)) {
  function user_account_presave_user_presave(&amp;$edit, $account, $category) { 
    global $user;

    // Load profile2.
    $profile = profile2_load_by_user(array('type' =&gt; 'next', 'uid' =&gt; $user &gt;uid));

    // Add in the necessary custom fields and values.
    $profile-&gt;field_next_destination['und'][] = array(
      'longitude' =&gt; '0.0',
      'latitude' =&gt; '0.0',
    );

    // Save the profile2 to the user account.
    profile2_save($profile);

  }
}


I am not sure if the IF statement should be in the Function, but if it is not, the Function fails to allow users to register because the CAPTCHA reuse attack function is triggered.

Has anyone ever run into this?

Thank you!
Try using hook_user_insert instead. The $account will have $account-&gt;uid set at that stage.

P.S wrapping hook_user_presave in that condition looks wrong and probably won't work with the hook registry cache.