Adding an autoresponder to a registration form
-
- Joomla! Apprentice
- Posts: 17
- Joined: Sun Sep 06, 2009 4:11 pm
Adding an autoresponder to a registration form
Hi
I am trying to add an auto-responder to a registration form so that when the user registers, the program will send a form message to their e-mail
Can anyone tell me how to go about doing this?
Thanks
Star6966
I am trying to add an auto-responder to a registration form so that when the user registers, the program will send a form message to their e-mail
Can anyone tell me how to go about doing this?
Thanks
Star6966
- ooffick
- Joomla! Master
- Posts: 11616
- Joined: Thu Jul 17, 2008 3:10 pm
- Location: Ireland
- Contact:
Re: Adding an autoresponder to a registration form
Hi,
which version of Joomla do you have?
Olaf
which version of Joomla do you have?
Olaf
Olaf Offick - Global Moderator
learnskills.org
learnskills.org
-
- Joomla! Apprentice
- Posts: 17
- Joined: Sun Sep 06, 2009 4:11 pm
- ooffick
- Joomla! Master
- Posts: 11616
- Joined: Thu Jul 17, 2008 3:10 pm
- Location: Ireland
- Contact:
Re: Adding an autoresponder to a registration form
Please migrate to Joomla 1.5:
http://docs.joomla.org/Upgrading_1.5_fr ... 5x_version
Please note the Joomla 1.0 End-of-Life notice:
http://community.joomla.org/blogs/commu ... f-age.html
Olaf
http://docs.joomla.org/Upgrading_1.5_fr ... 5x_version
Please note the Joomla 1.0 End-of-Life notice:
http://community.joomla.org/blogs/commu ... f-age.html
Olaf
Olaf Offick - Global Moderator
learnskills.org
learnskills.org
-
- Joomla! Apprentice
- Posts: 17
- Joined: Sun Sep 06, 2009 4:11 pm
Re: Adding an autoresponder to a registration form
ok
how would I do it in 1.5?
how would I do it in 1.5?
- ooffick
- Joomla! Master
- Posts: 11616
- Joined: Thu Jul 17, 2008 3:10 pm
- Location: Ireland
- Contact:
Re: Adding an autoresponder to a registration form
In Joomla 1.5 you would create a small plugin which listens on an Event like onAfterStoreUser:
http://docs.joomla.org/Reference:User_E ... rStoreUser
Olaf
http://docs.joomla.org/Reference:User_E ... rStoreUser
Olaf
Olaf Offick - Global Moderator
learnskills.org
learnskills.org
-
- Joomla! Apprentice
- Posts: 17
- Joined: Sun Sep 06, 2009 4:11 pm
Re: Adding an autoresponder to a registration form
Ok
and how would I get it to send a message
I am pretty new at this kind of programing
Thanks alot
Star6966
and how would I get it to send a message
I am pretty new at this kind of programing
Thanks alot
Star6966
-
- Joomla! Apprentice
- Posts: 17
- Joined: Sun Sep 06, 2009 4:11 pm
Re: Adding an autoresponder to a registration form
would this work in 1.5?
function onAfterStoreUser($user, $isnew, $success, $msg)
{
global $mainframe;
$args = array();
$args['username'] = $user['username'];
$args['email'] = $user['email'];
$args['fullname'] = $user['name'];
$args['password'] = $user['password'];
if ($isnew)
{
$message = "Test"
$subject = "Test Mail"
mail ($user['email'],$subject,$message,)
}
else
{
}
}
function onAfterStoreUser($user, $isnew, $success, $msg)
{
global $mainframe;
$args = array();
$args['username'] = $user['username'];
$args['email'] = $user['email'];
$args['fullname'] = $user['name'];
$args['password'] = $user['password'];
if ($isnew)
{
$message = "Test"
$subject = "Test Mail"
mail ($user['email'],$subject,$message,)
}
else
{
}
}
- ooffick
- Joomla! Master
- Posts: 11616
- Joined: Thu Jul 17, 2008 3:10 pm
- Location: Ireland
- Contact:
Re: Adding an autoresponder to a registration form
You might want to use the JMail class instead:
http://api.joomla.org/Joomla-Framework/Mail/JMail.html
Olaf
http://api.joomla.org/Joomla-Framework/Mail/JMail.html
Olaf
Olaf Offick - Global Moderator
learnskills.org
learnskills.org
-
- Joomla! Apprentice
- Posts: 17
- Joined: Sun Sep 06, 2009 4:11 pm
Re: Adding an autoresponder to a registration form
so i would replace mail with JMail
would it still have the form in terms of the
JMail($user['email'],$subject,$message,)?
would it still have the form in terms of the
JMail($user['email'],$subject,$message,)?
- ooffick
- Joomla! Master
- Posts: 11616
- Joined: Thu Jul 17, 2008 3:10 pm
- Location: Ireland
- Contact:
Re: Adding an autoresponder to a registration form
No, it would be more like this:
Olaf
Code: Select all
$mail = JFactory::getMailer();
$mail->addRecipient( $recipient );
$mail->setSender( array( $email, $name ) );
$mail->setSubject($subject );
$mail->setBody( $body );
$sent = $mail->Send();
Olaf Offick - Global Moderator
learnskills.org
learnskills.org
-
- Joomla! Apprentice
- Posts: 17
- Joined: Sun Sep 06, 2009 4:11 pm
Re: Adding an autoresponder to a registration form
So to recap
Would this send an email to a user that created a new account?
Would this send an email to a user that created a new account?
Code: Select all
function onAfterStoreUser($user, $isnew, $success, $msg)
{
global $mainframe;
$args = array();
$args['username'] = $user['username'];
$args['email'] = $user['email'];
$args['fullname'] = $user['name'];
$args['password'] = $user['password'];
if ($isnew)
{
$body = "Test"
$subject = "Test Mail"
$email = $user['email']
$name = $user['name']
$recipient = $user['name']
$mail = JFactory::getMailer();
$mail->addRecipient( $recipient );
$mail->setSender( array( $email, $name ) );
$mail->setSubject($subject );
$mail->setBody( $body );
$sent = $mail->Send();
}
else
{
}
}
-
- Joomla! Apprentice
- Posts: 17
- Joined: Sun Sep 06, 2009 4:11 pm
Re: Adding an autoresponder to a registration form
hey is this right
I just need to know so I can get it up and working
thanks
Star6966
I just need to know so I can get it up and working
thanks
Star6966
- ooffick
- Joomla! Master
- Posts: 11616
- Joined: Thu Jul 17, 2008 3:10 pm
- Location: Ireland
- Contact:
Re: Adding an autoresponder to a registration form
Well, that looks ok. Did you try it? Does is work?
Olaf
Olaf
Olaf Offick - Global Moderator
learnskills.org
learnskills.org
-
- Joomla! Apprentice
- Posts: 17
- Joined: Sun Sep 06, 2009 4:11 pm
Re: Adding an autoresponder to a registration form
i can't try it yet
we are still in the process of migrating to 1.5
i intend to try it as soon as the site is back up and running
we are still in the process of migrating to 1.5
i intend to try it as soon as the site is back up and running
-
- Joomla! Apprentice
- Posts: 17
- Joined: Sun Sep 06, 2009 4:11 pm
Re: Adding an autoresponder to a registration form
so I tried it and nothing
I am not sure if it has something to do with the way i installed it
or maybe the rest of the code
i am posting the entire code here
that is the .php file
and here is the .xml file
I have the files
test.php
and
test.xml
in a zip file which i can install, but if i register a user, no response
any suggestions
I am not sure if it has something to do with the way i installed it
or maybe the rest of the code
i am posting the entire code here
Code: Select all
<?php
defined('_JEXEC') or die( 'Restricted access' );
jimport('joomla.plugin.plugin');
class plgUserExample extends JPlugin
{
function onAfterStoreUser($user, $isnew, $success, $msg)
{
global $mainframe;
$args = array();
$args['username'] = $user['username'];
$args['email'] = $user['email'];
$args['fullname'] = $user['name'];
$args['password'] = $user['password'];
if ($isnew)
{
$body = "Test"
$subject = "Test Mail"
$email = $user['email']
$name = $user['name']
$recipient = $user['name']
$mail = JFactory::getMailer();
$mail->addRecipient( $recipient );
$mail->setSender( array( $email, $name ) );
$mail->setSubject($subject );
$mail->setBody( $body );
$sent = $mail->Send();
}
else
{
}
}
}
and here is the .xml file
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<install version="1.5.2" type="plugin" group="system" method="upgrade">
<name>System - Test</name>
<author>Erik Smith</author>
<creationDate>September 2009</creationDate>
<copyright>Copyright (C) 2008 Holder. All rights reserved.</copyright>
<license>GNU General Public License</license>
<authorEmail>[email protected]</authorEmail>
<authorUrl></authorUrl>
<version>1.0.1</version>
<description>A test system plugin</description>
<files>
<filename plugin="example">test2.php</filename>
</files>
<params>
<param name="Test"
type="text"
default=""
label="Test"
description="An example text parameter" />
</params>
</install>
test.php
and
test.xml
in a zip file which i can install, but if i register a user, no response
any suggestions
- ooffick
- Joomla! Master
- Posts: 11616
- Joined: Thu Jul 17, 2008 3:10 pm
- Location: Ireland
- Contact:
Re: Adding an autoresponder to a registration form
and did you enable the plugin in the plugin manager?
Olaf
Olaf
Olaf Offick - Global Moderator
learnskills.org
learnskills.org
-
- Joomla! Apprentice
- Posts: 17
- Joined: Sun Sep 06, 2009 4:11 pm
- ooffick
- Joomla! Master
- Posts: 11616
- Joined: Thu Jul 17, 2008 3:10 pm
- Location: Ireland
- Contact:
Re: Adding an autoresponder to a registration form
The code is missing a couple of semicolons and the Recipient is not an email address. Moreover, the name of the plugin is test2 and in the system group but your plugin class is using this plgUserExample
You can also check if the mail was send like this:
http://docs.joomla.org/JFactory/getMailer
Olaf
You can also check if the mail was send like this:
http://docs.joomla.org/JFactory/getMailer
Olaf
Olaf Offick - Global Moderator
learnskills.org
learnskills.org
-
- Joomla! Apprentice
- Posts: 17
- Joined: Sun Sep 06, 2009 4:11 pm
Re: Adding an autoresponder to a registration form
So here is the code thus far
I am still not sure what to put for the address
I am still not sure what to put for the address
Code: Select all
<?php
defined('_JEXEC') or die( 'Restricted access' );
jimport('joomla.plugin.plugin');
class test2 extends JPlugin
{
function onAfterStoreUser($user, $isnew, $success, $msg)
{
global $mainframe;
$args = array();
$args['username'] = $user['username'];
$args['email'] = $user['email'];
$args['fullname'] = $user['name'];
$args['password'] = $user['password'];
if ($isnew)
{$mail =& JFactory::getMailer();
$config =& JFactory::getConfig();
$mail->addRecipient( $config->getValue( 'What do I put here' ) );
$mail->setSubject( 'Test message' );
$mail->setBody( 'This is an example email to test the Joomla! JFactory::getMailer() method. Please ignore it' );
if ($mail->Send()) {
echo "Mail sent successfully.";
} else {
echo "An error occurred. Mail was not sent.";
}
else
{
}
}
}
- ooffick
- Joomla! Master
- Posts: 11616
- Joined: Thu Jul 17, 2008 3:10 pm
- Location: Ireland
- Contact:
Re: Adding an autoresponder to a registration form
the class is not test2, it would be more like this plgSystemTest2
or if you use the group user: plgUserTest2
Olaf
or if you use the group user: plgUserTest2
Olaf
Olaf Offick - Global Moderator
learnskills.org
learnskills.org
-
- Joomla! Apprentice
- Posts: 17
- Joined: Sun Sep 06, 2009 4:11 pm
Re: Adding an autoresponder to a registration form
anything else?
- ooffick
- Joomla! Master
- Posts: 11616
- Joined: Thu Jul 17, 2008 3:10 pm
- Location: Ireland
- Contact:
Re: Adding an autoresponder to a registration form
Who is the supposed to be the recipient? You might want to consider to use a user plugin instead of a system plugin.
Olaf
Olaf
Olaf Offick - Global Moderator
learnskills.org
learnskills.org
-
- Joomla! Apprentice
- Posts: 17
- Joined: Sun Sep 06, 2009 4:11 pm
Re: Adding an autoresponder to a registration form
I want the recipient to be every new user
- ooffick
- Joomla! Master
- Posts: 11616
- Joined: Thu Jul 17, 2008 3:10 pm
- Location: Ireland
- Contact:
Re: Adding an autoresponder to a registration form
well, then you would need to use the email address in the $mail->addRecipient method:
Code: Select all
$mail->addRecipient($user['email']);
Olaf Offick - Global Moderator
learnskills.org
learnskills.org
-
- Joomla! Apprentice
- Posts: 17
- Joined: Sun Sep 06, 2009 4:11 pm
Re: Adding an autoresponder to a registration form
what is the difference between a user plugin and a system plugin
- ooffick
- Joomla! Master
- Posts: 11616
- Joined: Thu Jul 17, 2008 3:10 pm
- Location: Ireland
- Contact:
Re: Adding an autoresponder to a registration form
Have a look here:
http://docs.joomla.org/Reference:System ... gin_System
http://docs.joomla.org/Reference:User_E ... gin_System
Olaf
http://docs.joomla.org/Reference:System ... gin_System
http://docs.joomla.org/Reference:User_E ... gin_System
Olaf
Olaf Offick - Global Moderator
learnskills.org
learnskills.org