☆スキーウエアNOW ON SALE!!☆★2ピース上下スーツ★ 【エァウォーク】幼児用ウエアAWT‐5524 ピンク(桃色)サイズ:100・110・120
沖縄産スナックパイン1玉(500g〜800g) N−95D23L/C3 technorati RobotReplay 2004/09/30から 今日: 昨日: 最近のツッコミ10発 |
2007-07-24 Drupalいじり_ [Know-How][OpenSource][Software] Drupalの新規アカウントのアクテイブ時にメール送信DrupalというオープンソースのCMSがあるのですが、「新規アカウントの登録方法」を「訪問者が新規アカウントを作成できるが、管理者の承認が必要」に設定し、新規アカウントを「アクティブ」時にメールが飛ぶようにしてみた。 こんな感じでサクッと出来きた。 $ diff -u modules/user/user.module.org modules/user/user.module --- modules/user/user.module.org 2007-07-24 19:29:02.000000000 +0900 +++ modules/user/user.module 2007-07-24 19:29:18.000000000 +0900 @@ -111,6 +111,17 @@ user_module_invoke('update', $array, $account, $category); $data = unserialize(db_result(db_query('SELECT data FROM {users} WHERE uid = %d', $account->uid))); + if ($account->status == 0 && $array['status'] == 1) { + global $base_url; + + $from = variable_get('site_mail', ini_get('sendmail_from')); + $variables = array('!username' => $account->name, '!site' => variable_get('site_name', 'Drupal'), '!uri' => $base_url); + $subject = _user_mail_text('user_active_subject', $variables); + $body = _user_mail_text('user_active_body', $variables); + $mail_success = drupal_mail('user-active', $account->mail, $subject, $body, $from); + + } + foreach ($array as $key => $value) { if ($key == 'pass' && !empty($value)) { $query .= "$key = '%s', "; @@ -157,6 +168,7 @@ // Refresh user object $user = user_load(array('uid' => $account->uid)); user_module_invoke('after_update', $array, $user, $category); + } else { $array['uid'] = db_next_id('{users}_uid'); @@ -1551,6 +1563,10 @@ return t('Replacement login information for !username at !site', $variables); case 'pass_body': return t("!username,\n\nA request to reset the password for your account has been made at !site.\n\nYou may now log in to !uri_brief clicking on this link or copying and pasting it in your browser:\n\n!login_url\n\nThis is a one-time login, so it can be used only once. It expires after one day and nothing will happen if it's not used.\n\nAfter logging in, you will be redirected to !edit_uri so you can change your password.", $variables); + case 'user_active_subject': + return t('Effective for !username at !site', $variables); + case 'user_active_body': + return t("!username,\n\nYour account became effective..\n\nYou may now log in to !site here(!uri).", $variables); } } } |