/** * Verify user and update user's status * @param params User fields, includes email */ function civicrm_drupal_user_update_and_redirect($params) { global $user; if (!($params['email'] && $params['drupalID'] && $params['password'])) { return false; } $user_fields['uid'] = $params['drupalID']; $user_fields['mail'] = $params['email']; $user = user_load($user_fields); if (!$user->uid) { return false; } $update = array(); $update['status'] = 1; $update['pass'] = $params['password']; $user = user_save($user, $update); // Login the user $edit = array(); user_module_invoke('login', $edit, $user); // redirect user to locker drupal_goto('locker'); }
<?php global $user; tzbase_include_proto_classes(); $account = user_load(array('name' => 'Johan Heander')); if ($account) { TZIntellitimeBot::destroy_session_data($account->intellitime_session_data); user_save($account, array('intellitime_session_data' => NULL)); } // Login and logout to refresh cookie $form_state = array('values' => array('name' => 'Johan Heander', 'pass' => '0733623516', 'op' => t('Log in'))); drupal_execute('user_login', $form_state); // Destroy the current session: session_destroy(); // Only variables can be passed by reference workaround. $null = NULL; user_module_invoke('logout', $null, $user); // Load the anonymous user $user = drupal_anonymous_user(); tzintellitime_sync_synchronize_users(); TZIntellitimeBot::destroy_session_data($account->intellitime_session_data);
/** * This function is copying the same code from legal. */ function devis_form_legal_login_submit($form, &$form_state) { // This is a copy from the legal module. global $user; $values = $form_state['values']; $user = user_load($values['uid']); $redirect = 'user/' . $user->uid; if (!empty($_GET['destination'])) { $redirect = $_GET['destination']; } $form_state['redirect'] = $redirect; // Update the user table timestamp noting user has logged in. db_update('users')->fields(array('login' => time()))->condition('uid', $user->uid)->execute(); // User has new permissions, so we clear their menu cache. cache_clear_all($user->uid, 'cache_menu', TRUE); // Fixes login problems in Pressflow. drupal_session_regenerate(); user_module_invoke('login', $edit, $user); }