0

Its been along time since iv done any joomla development work so a bit rusty here. I have a joomla site with a user registration page and I need to call another script or webservice after the user signs up. I want use the signup details to create a user in another program. So basically they register for joomla and also register for my other program at the same time. I would prefer that the other script is called after they verify their email address in joomla.

What is the best way to do this in an upgrade safe way? Can anybody point me in the direction of a tutorial or something that is similar.

ok I have my basic plugin set-up:

Code:

  defined('_JEXEC') or die('Access Denied');

  class plgUserSugarusercreator extends JPlugin {

  function onUserAfterSave($user, $isnew, $success, $msg){

   }
}

I guess Ill have to use the onAfterSave method but how do I determine when the user is actually activated? I dont want the function fire if its new or just on every save but only when the user is activated.

user794846
  • 1,881
  • 5
  • 29
  • 72
  • The best way would be to develop a plugin that executes your code after the user registers. I suggest a plugin as it's better to change site behavior, rather than editing the core files for an "upgrade safe way". http://docs.joomla.org/Portal:Plugin_Development – Lodder Dec 13 '13 at 13:21
  • I have my basic plgin structure set-up but Im not sure how to ensure my custom code will only fire when the user has been activated. – user794846 Dec 13 '13 at 15:37
  • I don't think there is an onAfterActivate event. http://docs.joomla.org/Plugin/Events Obviously you have the $isnew so you will know that it is not new easily. I think you might be better of doing it before save rather than after so that you will know the old value of activated, then you could maybe take that information and after successful save compare it to the new value – Elin Dec 14 '13 at 13:19

1 Answers1

0

There is no event bound to the activation of a user, and since the activation can happen in different ways depending on the configuration, or not be required at all, you are left with another option.

If the user is activated eventually they will login. This can be also achieved automatically, when they click on the activation link, thank to a couple of plugins on the JED in authentication.

So you just create your secondary system login the first time the user enters the onUserLogin() event. You will need to store the information that the remote login was created so you don't do it over and over (could use a user profile plugin for this). Additionally you need to bind two more events:

onUserAfterSave
onUserAfterDelete

if you want to keep your two systems in sync.

Riccardo Zorn
  • 5,590
  • 1
  • 20
  • 36