MyBB Community Forums

Full Version: PM On Registration plugin didn't work
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I download the PM on registration plugin and upload the plugin file at /inc/plugins/pmonreg

Then I go to my ACP > Plugins and click Activate at PM on reg. plugin. But it didn't work because when I click Activate it show below message.

Quote:MyBB SQL Error

MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
1146 - Table 'podi_13521582_12381.mybb_mybb_settinggroups' doesn't exist
Query:
DELETE FROM mybb_mybb_settinggroups WHERE name = 'postonreg'

Please contact the MyBB Group for support.

My forum url is http://www.forumforu.uni.me
Which one you have downloaded?
This?
http://mods.mybb.com/view/pm-on-registration-v1.1.2

This?
http://mods.mybb.com/view/pm-on-registration

Those are all for old versions and though I didn't see inside, I guess it needs a compatibility revision / upgradation in codes as the error reflects repeated table prefix ...
I don't download it form mods.mybb.com website
I download from another website.
439 - pmonregv1.1.2
If its a free plugin you can share the code for review; however plugins from mods site are always authentic and recommended.
Yes it's a free plugin.

<?php
// PM On Registration Plugin
// By DennisTT
// Version 1.1.2

// This plugin (C) 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.2.x",
		"website"		=> "http://www.dennistt.net",
		"author"		=> "DennisTT",
		"authorsite"	=> "http://www.dennistt.net",
		"version"		=> "1.1.2",
	);
}

// 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);
}
Try this:

<snip>
There are more problem . When I make a new account it seen this message at thank you page

The following warnings occurred:
Warning [2] Invalid argument supplied for foreach() - Line: 559 - File: inc/datahandlers/pm.php PHP 5.3.24 (Linux)
File Line Function
/inc/datahandlers/pm.php 559 errorHandler->error
/inc/plugins/pmonreg.php 117 PMDataHandler->insert_pm
[PHP] pmonreg_run
/inc/class_plugins.php 101 call_user_func_array
/member.php 272 pluginSystem->run_hooks

I still activated this. Just go to my forum and try to Sing Up.
http://www.forumforu.uni.me
The latest:

[attachment=29954]
Thanks effone.
For any developer guessing what was wrong:

$db->insert_query(TABLE_PREFIX."settings", $insert_array);

This is wrong. insert_query already and automatically adds TABLE_PREFIX to your queries.
Pages: 1 2