Page 1 of 1

Login info mailer

Posted: Sat Oct 28, 2006 7:50 pm
by 10010110
YES! I did it! :) I created a script that is sending the login info by email to a newly created user. However, since my knowledge of PHP is very basic yet I'm sure there are some things to improve and I'm open for suggestions.
I just copied the mailer script from the install.php (since there is an option to send the CMS admin login details by email) and modified it accordingly. Here's the script to put in a user defined tag:

Code: Select all

//$link = str_replace(" ", "%20", $_POST['docroot']);


if (isset($_POST["email"])) 
{
		echo "<p>E-mailing user account information...";
		$to      = $_POST["email"];
		$subject = 'CMS Account Information';
		$message = <<<EOF
You have been added as new user to CMSmadesimple.

This is your new account information:
username: {$_POST["user"]}
password: {$_POST["password"]}

Log into the site admin here: /*$link*/ http://example.com/admin/
EOF;
		echo (
				@mail($to, $subject, $message)
				? '[done]'
				: '<strong>[failed]</strong>'
		);
		echo '</p>';
}
However, the automatic link ($link variable) isn't working yet (I commented it out for now). Does anybody have an idea?
This user defined tag must be attached to the event "AddUserPost" in the event list.

OK, I'm open for suggestions. :)

Re: Login info mailer

Posted: Tue Oct 31, 2006 5:18 pm
by tsw
nice, wanna add that into wiki udt pages, maybe even create a new section for udt's which work as event handlers

Re: Login info mailer

Posted: Wed Nov 01, 2006 3:56 pm
by 10010110
OK, but still I need to find out how to get the $link variable (which will post the URL) working. And I think I'm gonna modify it a bit more. But as this is open source I'm open to suggestions and improvements (especially from more savvy developers).

Re: Login info mailer

Posted: Wed Nov 01, 2006 5:13 pm
by tsw
global $config;
echo $config['root_url'] . "/". $config['admin_dir'];

might help