All pastes #948073 Raw Edit

autopm install

public text v1 · immutable
·published 2008-03-18 21:43 UTC
rendered paste body
Auto-PM install:
/*
+----------------------------------------------------
| New User Welcome PM 1.0.0
| ===================================================
| by Nguyen Tuan Dung (ntd1712)
| (c) 2006 Vietnamese - Invision Resources
| http://invisionviet.net/
| ===================================================
| Date Started: Fri, 24 Feb 2006 19:16 (GMT+07:00)
| Release Data: Sat, 25 Feb 2006 20:21 (GMT+07:00)
| License Info: http://invisionviet.net/license.php
+----------------------------------------------------
*/

Compatibility: IPB v2.1.x
Last Updated : Sat, 01 Apr 2006 23:20
Description:
- This hack will send any new users a welcome PM.
- Can be edited via ACP - View General Settings - New User Welcome PM

File to edit:
./sources/action_public/register.php

File to upload:
.\ipb_settings_partial.xml --> ./ipb_settings_partial.xml

---------------------------------------------------------------------------------------------

First, go to in ACP - TOOLS & SETTINGS - View All General Settings - Import an XML settings file:
click on "Import XML settings Set" button

---------------------------------------------------------------------------------------------

Open: ./sources/action_public/register.php

Find: [ In function create_account() ]

		//-----------------------------------------
		// Validation key
		//-----------------------------------------

Add Above:

		if( $this->ipsclass->vars['wp_enable'] == 1 )
		{
			$this->auto_pm( $member );
		}

==============================================

Find: [ In function validate_user() ]

				$this->ipsclass->boink_it($this->ipsclass->base_url.'&act=Login&CODE=autologin&fromreg=1');
				}
				
				//-----------------------------------------
				// ADMIN-VERIFICATION...
				//-----------------------------------------

Add Above:

				if( $this->ipsclass->vars['wp_enable'] == 1 )
				{
					$this->auto_pm( $member );
				}

==============================================

Find:

}

?>

Add Above:

	function auto_pm($member=array())
	{
		$this->ipsclass->vars['max_post_length'] = $this->ipsclass->vars['max_post_length'] ? $this->ipsclass->vars['max_post_length'] : 2140000;
		$msg = preg_replace("/<#NEW_USER#>/", $member['members_display_name'], $this->ipsclass->vars['wp_text']);
		$this->ipsclass->member['id'] = intval($this->ipsclass->vars['wp_from']);

		if( ( strlen(trim($msg)) > 1 ) && ( strlen($msg) < ($this->ipsclass->vars['max_post_length'] * 1024) ) )
		{
			require_once( ROOT_PATH.'sources/lib/func_msg.php' );
			$msglib = new func_msg();
			$msglib->ipsclass =& $this->ipsclass;
			$msglib->init();

			$msglib->postlib->parser->parse_smilies = 1;
			$msglib->postlib->parser->parse_bbcode  = 1;

			$msglib->to_by_id    = $member['id'];
			$msglib->from_member = $this->ipsclass->member;
			$msglib->msg_title   = $this->ipsclass->vars['wp_subject'];
			$msglib->msg_post    = $msglib->postlib->parser->pre_db_parse( $msg );

			$msglib->send_pm();

			if( $msglib->error ) return FALSE;
		}

		return TRUE;
	}

---------------------------------------------------------------------------------------------
That's all! :)
©2006 ntd1712