Login info mailer

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
10010110

Login info mailer

Post 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. :)
Last edited by 10010110 on Wed Nov 01, 2006 3:53 pm, edited 1 time in total.
tsw
Power Poster
Power Poster
Posts: 1408
Joined: Tue Dec 13, 2005 10:50 pm

Re: Login info mailer

Post by tsw »

nice, wanna add that into wiki udt pages, maybe even create a new section for udt's which work as event handlers
10010110

Re: Login info mailer

Post 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).
tsw
Power Poster
Power Poster
Posts: 1408
Joined: Tue Dec 13, 2005 10:50 pm

Re: Login info mailer

Post by tsw »

global $config;
echo $config['root_url'] . "/". $config['admin_dir'];

might help
Post Reply

Return to “Tips and Tricks”