'Welcome message configure', 'page callback' => 'drupal_get_form', 'page arguments' => array('welcome_admin_settings'), 'access arguments' => array('administer users'), 'type' => MENU_NORMAL_ITEM, 'file' => 'welcome.admin.inc', ); return $items; } /** * Implements hook_user_login(). */ function welcome_user_login(&$edit, $account) { $message = welcome_get_message($account); $message_replaced = token_replace($message, array('user' => $account)); drupal_set_message(t($message_replaced)); } /** * Implements hook_theme(). */ function welcome_theme() { return array( 'welcome_admin_settings' => array( 'render element' => 'form', 'file' => 'welcome.admin.inc', ), ); } /** * Get message for current user. */ function welcome_get_message($account) { $roles = $account->roles; $rid = array_keys($roles); $query = db_select('welcome_message', 'wm') ->fields('wm', array('rid', 'message', 'weight')) ->condition('rid', $rid, 'IN') ->orderBy('weight', 'ASC') ->range(0, 1); $result = $query->execute(); $message = $result->fetch(); return $message->message; } /** * Implements hook_help(). */ function welcome_help($path, $arg) { switch ($path) { case 'admin/config/people/welcome': $output = '

' . t('Welcome message per role. Drag to order. If a user has more than one role, highest weighted role will be used.') . '

'; return $output; } }