Forums

create follow up email after Joomla registration validated

samoht 30 Apr, 2011
Hello all,

I have my registration form set up and updating the appropriate tables. Users must validate their registration before login and an email is sent with the activation code just fine. However, I would like to send a follow up email (welcome email) after a user activates their account.

Any Ideas??
GreyHead 01 May, 2011
Hi Samoht,

You can do this by using a custom Verification Link that points to one of the Extra Code boxes for your form. You need to add the code in there to verify the link; enable the user and send the email.

Alternatively you could have the link point to a second ChronoForm with just a 'Confirm' button - that way you can use the ChronoForms mailer to send the message.

Bob
samoht 12 May, 2011
Hey Bob,

Thanks for this response but I didn't quite understand it.
I have the Joomla set up to require activation. I noticed that jos_users does not have a date activated field only an activation field that stores some md5 hash if the user has not followed the activation URL sent to them via email.

So I can I trigger an event on activation and use chronoforms to mail a response?
Will I need to create another table that stores the date of the response and the user_id so I can see who the responses have been sent to?

Thanks,
GreyHead 12 May, 2011
Hi samoht,

It sounds as if you are almost there.

You can either store your own verification codes or use the Joomla! ones.

When you get a result from a verification link you parse the URL to get the values; check that the code matches one that is waiting verification then set the user to Unblocked.

It's hard to write much more without getting deep into the code.

Bob
samoht 12 May, 2011
Thanks again for the reply,

I need a bit more unfortunately.
1. How do I create a custom verification link?

Once I get that nailed down I should be able to do the rest (hopefully)

Thanks,
GreyHead 13 May, 2011
Hi samoht,

Nothing very complicated - its going to look like this
http://mysite.com/index.php?option=com_chronocontact&chronformname=my_form_name&task=extra&vid={some_long_random_string}


Then you add code in the Extracode 1 box for that form to check the value of vid.

I think that the Joomla! User Helper has a function that can create a 'vid' string for you.

Bob
samoht 13 May, 2011
Hey Bob,

If I am still using chronoforms V. 3 - where would I put the code to create activation URL?
I assume that by using the Joomla core registration and setting it to require activation - my chronoform triggers com_user and creates the activation URL and then sends out the email. So if I want to do this with a custom activation I need to not use com_user right?

If that is right - I suppose I should turn OFF the Joomla core "Require Activation" setting. And then use my chronoform registration form to email the user?
GreyHead 14 May, 2011
Hi samoht,

The code would go in one of he OnSubmit boxes.

You would still use com_user - you ae just replacing the Joomla! verification step.

You still want Require Activation on - just that you are going to do the check and update the user profile when you have checked.

Bob
samoht 14 May, 2011
OK, I think I am almost done asking questions 🙂

So I think I need to get the user object from Joomla to use this code for the URL:
<?php
$user->get('activation');
?>

[list=1]
  • Does that mean that the OnSubmit would be "after" ?? Or is the fact that I am sending out an email from my Registration form make it so the OnSubmit should be before??

  • Also, what should I use to get the Joomla $user? (global $mainfame) ??
  • [/list:o]

    Thanks for all your help Bob!
    samoht 14 May, 2011
    So I tried this in the OnSubmit Before of my Registration form:
    <?php
    	global $mainframe;
    	
    	$siteURL	= JURI::base();
    	
        JRequest::setVar('activationURL', $siteURL."index.php?option=com_chronocontact&chronformname=SurgimapReg&task=extra&vid=". $user->get('activation'));
        JRequest::setVar('name', JRequest::getVar("first_name")." ".JRequest::getVar("last_name"));


    And that gave me this error:

    Fatal error: Call to a member function get() on a non-object in C:\xampp\htdocs\andy\components\com_chronocontact\libraries\customcode.php(64) : eval()'d code on line 6

    samoht 14 May, 2011
    I figured out a work around - but now have tow problems left.

    [list=1]
  • For some reason I'm sending out 2 emails (almost duplicate but the first one does not have the activation URL in it)

  • The second form that performs the check on the activation is not updating the db
  • [/list:o]

    Here is my "Extra" code on my second form:
    <?php
    $activation = $_GET['vid'];
    $actdate = date('Y-m-d H:i:s');
    
    $db =& JFactory::getDBO();
    $query = '
    	UPDATE `jos_users`, `jos_vm_user_info` SET 
    	`block` = 0,
    	`activation` = "",
    	`activation_date` ="'.$actdate.'"
    	WHERE `activation` ='.$activation .' 
    	AND `jos_users`.`id` = `jos_vm_user_info`.`user_id` 
    ';
    
    $db->setQuery($query);
    $db->query();
    
    ?>
    
    <div class="form_item">
      <div class="form_element cf_heading">
        <h2 class="cf_text">Activation Complete!</h2>
      </div>
      <div class="cfclear"> </div>
    </div>
    
    <div class="form_item">
      <div class="form_element cf_text"> <span class="cf_text">Your Account has been successfully activated. You can now log in using the username and password you chose during the registration.</span> </div>
      <div class="cfclear"> </div>
    </div>

    I've tried the query in phpMyAdmin with hard data and it worked. - so I checked to make sure my vars had data in them and they do??

    Any Ideas?


    Oh and the work around looks like this:
    <?php
    global $mainframe;
    $siteURL	= JURI::base();
    
    $database =& JFactory::getDBO();
    $database->setQuery( '
    SELECT activation 
    FROM jos_users
    WHERE id = '.JRequest::getVar("cf_user_id").'
    ');
    $database->query();
    $act = $database->loadResult();
    
    JRequest::setVar('activationURL', $siteURL."index.php?option=com_chronocontact&chronoformname=regcomplete&task=extra&vid=".$act);
    ?>

    In the Joomla Registartion plugin Extra code after registration box.
    samoht 14 May, 2011
    Well, I fixed the issue of not updating the DB so now the two forms are working the way I want - with the one exception that I am still sending out 2 activation emails?

    I tried disabling the email on the registration form - but it still sends out two emails??
    weird?

    I'm very close though.
    mcarbone 09 Aug, 2011
    I am sorry for jumping in on the thread, but I have the same problem. My Joomla Registrations are sending 2 activation emails. One does not have an activation link in it. I am using Version 3.

    Thank you,
    CM
    mcarbone 09 Aug, 2011
    BTW...The email verification plugin is not turned on.
    mcarbone 09 Aug, 2011
    I am very sorry for the multiple posts. I have in the joomla registration plugin set to :

    E-mail the User? "Yes, From custom email 1"
    mcarbone 18 Aug, 2011
    I still need help with this.
    If I choose "E-mail the User? to "no", I only receive 1 email, but the "activation link" {vlink} is not activated in the email.

    If I Choose "Yes, (From custom email 1)" then I get 2 emails. Still stuck!
    GreyHead 20 Aug, 2011
    Hi mcarbone,

    Please go to the Email Setup | Properties box and disable the email i.e set Enabled to 'No'.

    The enable the Email from the Joomla! Registration Plug-in.

    I think this will do what you need.

    Bob
    mcarbone 07 Sep, 2011
    Hi Greyhead,

    Thank you for your help, sorry for the late response! Apparently I did not subscribe to the forum although this is serious situation for me.

    I tried exactly what you suggested, but that did not work. When I disable the emails in the form and choose "yes(from custom email 1)" in the Joomla registration plugin, I get two emails.

    CF v 3.x
    J 1.5.22

    here's a link:

    http://development.militaryconnection.com
    GreyHead 16 Sep, 2011
    Hi mcarbone ,

    I can't tell much from the front-end (and I'm not clear where the form is anyhow).

    By all means email or PM me the site URL and a SuperAdmin login and I'll take a quick look.

    Bob
    This topic is locked and no more replies can be posted.