"Emailbenachrichtigung bei neuer Registrierung" Variablen hinzufügen? - me.lina - 24.02.2014
Hi, es geht um dieses Plugin: https://www.mybb.de/erweiterungen/16x/plugins-moderation/email-about-new-members/
email_admin_new_member.php
Code: <?php
/**
* @version email_admin_new_member.php 2012-01-14
* @category MyBB.Plugins
* @package EmailAdminAboutNewUser
* @subpackage Plugin
* @author Malte Gerth <http://www.malte-gerth.de>
* @copyright Copyright (C) Malte Gerth. All rights reserved.
* @license GNU General Public License version 3 or later; see LICENSE.txt
*/
// Disallow direct access to this file for security reasons
if (!defined("IN_MYBB")) {
die("Direct initialization of this file is not allowed.<br />
<br />Please make sure IN_MYBB is defined.");
}
/** * *******************************************************************
* PLUGIN CODE
*/
function emailAdminAboutNewMember()
{
global $mybb, $db, $user_info;
if ($mybb->settings['emailonreg_onoff'] != "0") {
$subject = '';
$text = '';
$referrerUserInfo = null;
// query user information
$query = $db->simple_select(
"users",
"uid, username, email, regip, regdate, referrer",
"uid=" . (int)$user_info['uid'] . ""
);
$userInfo = $db->fetch_array($query);
// get referrer if exists
if (!empty($userInfo['referrer']) && (0 != $userInfo['referrer'])) {
$query = $db->simple_select(
"users",
"username",
"uid=" . $userInfo['referrer']
);
$referrerUserInfo = $db->fetch_array($query);
}
// get the email content
$subject = $mybb->settings['emailonreg_emailsubject'];
$text = $mybb->settings['emailonreg_emailtext'];
// replace placeholders
// %username %ip %uid %mailadress %date %referrer %bbname %bburl
$text = str_replace('%username', $userInfo['username'], $text);
$text = str_replace('%ip', $userInfo['regip'], $text);
$text = str_replace('%uid', $userInfo['uid'], $text);
$text = str_replace('%mailadress', $userInfo['email'], $text);
$text = str_replace('%date', $userInfo['regdate'], $text);
$text = str_replace('%referrer', $referrerUserInfo['username'], $text);
$text = str_replace('%bbname', $mybb->settings['bbname'], $text);
$text = str_replace('%bburl', $mybb->settings['bburl'], $text);
// send mail
my_mail($mybb->settings['emailonreg_email'], $subject, $text);
}
}
/** * *******************************************************************
* ADDITIONAL PLUGIN INSTALL/UNINSTALL ROUTINES
*
* _install():
* Called whenever a plugin is installed by clicking the "Install" button in the plugin manager.
* If no install routine exists, the install button is not shown and it assumed any work will be
* performed in the _activate() routine.
*
* function hello_install()
* {
* }
*
* _is_installed():
* Called on the plugin management page to establish if a plugin is already installed or not.
* This should return TRUE if the plugin is installed (by checking tables, fields etc) or FALSE
* if the plugin is not installed.
*
* function hello_is_installed()
* {
* global $db;
* if($db->table_exists("hello_world"))
* {
* return true;
* }
* return false;
* }
*
* _uninstall():
* Called whenever a plugin is to be uninstalled. This should remove ALL traces of the plugin
* from the installation (tables etc). If it does not exist, uninstall button is not shown.
*
* function hello_uninstall()
* {
* }
*
* _activate():
* Called whenever a plugin is activated via the Admin CP. This should essentially make a plugin
* "visible" by adding templates/template changes, language changes etc.
*
* function hello_activate()
* {
* }
*
* _deactivate():
* Called whenever a plugin is deactivated. This should essentially "hide" the plugin from view
* by removing templates/template changes etc. It should not, however, remove any information
* such as tables, fields etc - that should be handled by an _uninstall routine. When a plugin is
* uninstalled, this routine will also be called before _uninstall() if the plugin is active.
*
* function hello_deactivate()
* {
* }
*/
$plugins->add_hook("member_do_register_end", "emailAdminAboutNewMember");
function email_admin_new_member_info()
{
return array(
"name" => "Email Admin about new members",
"description" => "Send an email to an administrator if a new registration was made",
"website" => "https://www.mybb.de",
"author" => "Malte Gerth",
"authorsite" => "http://www.malte-gerth.de/mybb.html",
"version" => "2.1.0",
'guid' => '607b9c2229c876d962a7dd3bab3a4f96',
'compatibility' => '14*,16*',
);
}
function email_admin_new_member_activate()
{
global $db,$mybb;
$settingsGroup = array(
"gid" => "NULL",
"name" => "emailonreg",
"title" => "Email about new members",
"description" => "",
"disporder" => "50",
"isdefault" => "no",
);
$db->insert_query("settinggroups", $settingsGroup);
$gid = $db->insert_id();
$settingOnOff = array(
"sid" => "NULL",
"name" => "emailonreg_onoff",
"title" => "Plugin Active",
"description" => "Should an email being send if a new member has registered?",
"optionscode" => "yesno",
"value" => "0",
"disporder" => "1",
"gid" => intval($gid),
);
$db->insert_query("settings", $settingOnOff);
$settingRecipient = array(
"sid" => "NULL",
"name" => "emailonreg_email",
"title" => "Emailadresse",
"description" => "To which emailadresse should the message being send?<br />"
."<small>Seperate more than one adress with \",\"</small>",
"optionscode" => "text",
"value" => "email@domain.tld",
"disporder" => "2",
"gid" => intval($gid),
);
$db->insert_query("settings", $settingRecipient);
$settingMailSubject = array(
"sid" => "NULL",
"name" => "emailonreg_emailsubject",
"title" => "Subject",
"description" => 'The text which should be send to the administrator.',
"optionscode" => "text",
"value" => '[New User] A new member has signed up on '
.$db->escape_string($mybb->settings['bbname']),
"disporder" => "3",
"gid" => intval($gid),
);
$db->insert_query("settings", $settingMailSubject);
$settingMailText = array(
"sid" => "NULL",
"name" => "emailonreg_emailtext",
"title" => "Message",
"description" => 'The text which should be send to the administrator.<br />'
.'<small>You can use the following placeholders: '
.'%bburl %bbname %username %ip %uid %mailadress %date %referrer</small>',
"optionscode" => "textarea",
"value" => 'A new member has registered at ' . $mybb->settings['bbname'] . ".\n"
. "\n"
. "User Information\n"
. "User-ID: %uid \n"
. "Username: %username \n"
. "Emailadresse: %mailadress \n"
. "IP-Adresse: %ip ",
"disporder" => "3",
"gid" => intval($gid),
);
$db->insert_query("settings", $settingMailText);
rebuild_settings();
}
function email_admin_new_member_deactivate()
{
global $db;
$db->delete_query("settinggroups", "name='emailonreg'");
$db->delete_query(
"settings",
"name IN(
'emailonreg_onoff','emailonreg_email',
'emailonreg_emailsubject','emailonreg_emailtext'
)"
);
rebuild_settings();
}
Ich würde gerne weitere Informationen via E-Mail übermitteln. Also die Eigenen Profilfelder. Wie kann ich die integrieren?
(ich habs bisher über einen Umweg probiert - damit der Wert in der mybb_users-tabelle landet - und selber über member.php und co ein Feld erstellt und dann unter // query user information size hinzugefügt und unter // replace placeholders ebenso eine Zeile mit $text = str_replace('%size', $mybb->settings['size'], $text);
das hat aber nicht funktioniert)
Bestimmt ist das mit wenigen Handgriffen getan, aber ich kenn mich bisher nur wenig mit Datenbanken aus :/
lg
RE: "Emailbenachrichtigung bei neuer Registrierung" Variablen hinzufügen? - me.lina - 25.02.2014
Ok, da ja leider keiner geantwortet hat, hab ich gestern die Zeit investiert, mich reingelesen und via trial&error mit vielen schusselfehlern es letztendlich hinbekommen (die etwa 24h arbeit hätt ich nur lieber anderweilig investiert, deshalb die Frage im Forum)
Für alle mit dem selben Problem:
aus dem simple_select ein query machen:
$query = $db->query("SELECT uid, username, email, regip, regdate, referrer, size, ufid, fid4, fid5, fid7, fid8, fid9 FROM mybb_users, mybb_userfields WHERE mybb_users.uid=" . (int)$user_info['uid'] . " AND mybb_userfields.ufid=" . (int)$user_info['uid'] . "");
und dann unten jeweils die Zeilen hinzufügen:
$text = str_replace('%size', $userInfo['fid4'], $text);
....
|