You are here

function search_api_saved_searches_user_insert in Search API Saved Searches 7

Same name and namespace in other branches
  1. 8 search_api_saved_searches.module \search_api_saved_searches_user_insert()

Implements hook_user_insert().

If a new user already has saved searches with the same mail address, associate them with the new user. However, only do this if the user is already active.

File

./search_api_saved_searches.module, line 294
Offers the ability to save searches and be notified of new results.

Code

function search_api_saved_searches_user_insert(&$edit, $account, $category) {
  if (!empty($account->status)) {
    foreach (search_api_saved_search_load_multiple(FALSE, array(
      'mail' => $account->mail,
      'uid' => 0,
    )) as $search) {
      $search->uid = $account->uid;
      if (empty($search
        ->settings()->options['registered_user_delete_key'])) {
        unset($search->options['key']);
      }
      $search
        ->save();
    }
  }
}