MyBB Community Forums

Full Version: Wat is the plugin for welcome private msg?:S
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
title says!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!i just wanted!
http://mods.mybb.com/view/pm-on-registration-v1.1.2

Might need to change the compatibility though.
I did it like this:

Quote:<?php
// PM On Registration Plugin
// By DennisTT
// Version 1.6

// This plugin © DennisTT 2006. You may not redistribute this plugin without the permission from DennisTT.

function pmonreg_info()
{
return array(
"name" => "PM On Registration",
"description" => "Automatically send a private message to newly registered users. For MyBB 1.6.x",
"website" => "http://www.dennistt.net",
"author" => "DennisTT",
"authorsite" => "http://www.dennistt.net",
"version" => "1.6",
);
}

// This function runs when the plugin is activated.
function pmonreg_activate()
{
global $db, $cache;
$info = pmonreg_info();

$setting_group_array = array(
'name' => str_replace(' ', '_', 'dennistt_'.strtolower($info['name'])),
'title' => "$info[name] (DennisTT)",
'description' => "Settings for the $info[name] plugin",
'disporder' => 1,
'isdefault' => 'no',
);
$db->insert_query(TABLE_PREFIX.'settinggroups', $setting_group_array);
$group = $db->insert_id();

$settings = array(
'pmonreg_switch' => array('Send?', 'Send a private message on registration to new users?', 'yesno', 'yes'),
'pmonreg_uid' => array('Sent By Whom?', 'Enter the user ID of the author of these automated private messages.', 'text', '1'),
'pmonreg_subject' => array('PM Subject', 'Enter the subject of the automated private messages.', 'text', 'Welcome!'),
'pmonreg_message' => array('PM Message', 'Enter the message of the automated private messages.<br /><br />{username} will be replaced with the username of the recipient', 'textarea', 'Hello {username}, and welcome to my MyBB forum!'),
'pmonreg_showsignature' => array('Show Signature?', 'Show the sender\'s signature?', 'yesno', 'yes'),
'pmonreg_disablesmilies' => array('Disable Smilies?', 'Disable smilies from showing?', 'yesno', 'no'),
'pmonreg_savecopy' => array('Save A Copy?', 'Save a copy in the sender\'s Sent Items folder?', 'yesno', 'no'),
'pmonreg_receipt' => array('Request Read Receipt?', 'Request read receipt from recipient?', 'yesno', 'no'),
);

$i = 1;
foreach($settings as $name => $sinfo)
{
$insert_array = array(
'name' => $name,
'title' => $db->escape_string($sinfo[0]),
'description' => $db->escape_string($sinfo[1]),
'optionscode' => $db->escape_string($sinfo[2]),
'value' => $db->escape_string($sinfo[3]),
'gid' => $group,
'disporder' => $i,
);
$db->insert_query(TABLE_PREFIX."settings", $insert_array);
$i++;
}
rebuildsettings();

$cache->update('pmonreg_errors', 0);
}

// This function runs when the plugin is deactivated.
function pmonreg_deactivate()
{
global $db, $cache;
$info = pmonreg_info();

$result = $db->query("SELECT gid FROM ".TABLE_PREFIX."settinggroups WHERE title = '$info[name] (DennisTT)' LIMIT 1");
$group = $db->fetch_array($result);

if(!empty($group['gid']))
{
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE gid = $group[gid] LIMIT 1");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE gid = $group[gid]");
rebuildsettings();
}
$db->delete_query(TABLE_PREFIX."datacache", "title='pmonreg_errors'");
}

$plugins->add_hook("member_do_register_end", "pmonreg_run");
function pmonreg_run()
{
global $mybb, $user_info, $cache, $user;

if($mybb->settings['pmonreg_switch'] != "no")
{
require_once MYBB_ROOT."inc/datahandlers/pm.php";

$pmhandler = new PMDataHandler();

$pm = array(
"subject" => $mybb->settings['pmonreg_subject'],
"message" => str_replace('{username}', $user['username'], $mybb->settings['pmonreg_message']),
"icon" => -1,
"fromid" => intval($mybb->settings['pmonreg_uid']),
"toid" => $user_info['uid'],
"do" => '',
"pmid" => ''
);

$pm['options'] = array(
"signature" => $mybb->settings['pmonreg_showsignature'],
"disablesmilies" => $mybb->settings['pmonreg_disablesmilies'],
"savecopy" => $mybb->settings['pmonreg_savecopy'],
"readreceipt" => $mybb->settings['pmonreg_receipt']
);
$pm['saveasdraft'] = 0;
$pmhandler->admin_override = 1;
$pmhandler->set_data($pm);
if($pmhandler->validate_pm())
{
$pmhandler->insert_pm();
}
else
{
pmonreg_handle_error(&$pmhandler);
}
}
}

function pmonreg_handle_error(&$pmhandler)
{
global $cache;
$errors = $cache->read("rss2post_errors");
if($errors === false)
{
$errors = '';
}

$errors .= 'Date: ' . gmdate('r') . "\n";

$datahandler_errors = $pmhandler->get_errors();
ob_start();
print_r($datahandler_errors);
$errors .= ob_get_clean();
$errors .= "\n\n===========================================\n\n";

$cache->update('pmonreg_errors', $errors);
}
It show me error:MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
1146 - Table 'plathsc_no.mybb_mybb_settinggroups' doesn't exist
Query:
INSERT INTO mybb_mybb_settinggroups (name,title,description,disporder,isdefault) VALUES ('dennistt_pm_on_registration','PM On Registration (DennisTT)','Settings for the PM On Registration plugin','1','no')
This:
$db->insert_query(TABLE_PREFIX.'settinggroups', $setting_group_array);
Has to be:
$db->insert_query('settinggroups', $setting_group_array);

And this:
$db->insert_query(TABLE_PREFIX."settings", $insert_array);
Has to be:
$db->insert_query("settings", $insert_array);

Not sure how that's not been updated by Dennis.
You have to change
"version" => "1.6",
to this;
"compatibility" => "16*",
PM On Registration (DennisTT)

i leave Id 1?
(2010-11-18, 08:25 PM)TheUninvited Wrote: [ -> ]PM On Registration (DennisTT)

i leave Id 1?

yes if you were the first to join Big Grin
(2010-11-18, 07:34 PM)Yaldaram Wrote: [ -> ]You have to change
"version" => "1.6",
to this;
"compatibility" => "16*",

That's unrelated.
Then how you would define the compatibility ? :s
Yes but his error is not compatibility. Obviously his plugin is attempting to install which means it's past that code check.
Pages: 1 2