Joomla users are not created in Moodle automatically

  • Maxim
  • Topic Author
  • New Member
  • New Member
More
13 years 5 months ago #1 by Maxim
Please help me. I''m using Joomdle R0.82 for Joomla 1.6/1.7.x/2.5.x in Joomla 1.7 with Jomsocial and XIPT and I have the same problem as Martin here www.joomdle.com/en/forum/r07-support/818...-joomla-registration ! I can add Joomla users to Moodle manually, but I need it to be done automatically. I tried to turn on and off every single option in both joomdle, jomsocial and XIPT configuration, but I'm still can't have it working.

How can I debug onUserAfterSave function?

Please Log in or Create an account to join the conversation.

  • Maxim
  • Topic Author
  • New Member
  • New Member
More
13 years 5 months ago - 13 years 5 months ago #2 by Maxim
By debugging with dumpTrace(); (found in joomla extensions) I found out that onUserAfterSave function in "joomdle user hooks" plugin is never called. Whatever users I have created it fail to work. I don't know why it was silent.

I renamed the event name to onBigBang and added the following code at the begining of onLoginUser event function in jomsocialuser.php plugin file:
Code:
JPluginHelper::importPlugin('user'); $dispatcher =& JDispatcher::getInstance(); $results = $dispatcher->trigger('onBigBang',array( &$user, 0,0,0 ));

Than I had to completely clearify the code of my new onBigBang function in joomdlehooks and here it is. (Note: I want the moodle user to be created for every joomla user regardless of configuration, so I deleted some lines that you may need to keep. The only thing I check for is that a user does exist in moodle and it came clear that in original joomdlehooks file this check was incorrect!!! ). So here is my code :


Code:
/* Creates Moodle user */ function onBigBang ($user, $isnew, $success, $msg) { dumpTrace(); $mainframe =& JFactory::getApplication('site'); $last_visit = $user['lastvisitDate']; /// XXX Test this!!! if ($last_visit == 0) $isnew = 1; else $isnew = 0; dumpMessage($isnew); $comp_params = &JComponentHelper::getParams( 'com_joomdle' ); //XXX probar bien el isnew con y sin JS y simplicar esto, pa no ejecutar el get moodle user por ej $username = $user['username']; $str = $user['name']; $moodle_user = JoomdleHelperContent::call_method ("user_id", $username); /* Check Profile Types */ $use_xipt_integration = $comp_params->get( 'use_xipt_integration' ); //$use_profiletypes = $comp_params->get( 'use_profiletypes' ); if ((!$moodle_user) && ($use_profiletypes)) { /* Only create Moodle user if Profile Type in selected ones */ if ($use_profiletypes == 'xipt') { $mySess = & JFactory::getSession(); $profile_type = $mySess->get('SELECTED_PROFILETYPE_ID', 0, 'XIPT'); } else if ($use_profiletypes == 'jomsocial') { $profile_type = JRequest::getVar( 'profileType' ); } $profile_type_ids = JoomdleHelperProfiletypes::get_profiletypes_to_create (); $profile_ok = in_array ($profile_type, $profile_type_ids); //if ((!$profile_ok) && (!$moodle_user) ) // return; } /* If we reach here, user HAS to be created */ if (!$moodle_user) { $reply = JoomdleHelperContent::call_method ("create_joomdle_user", $username); } else { return; } // and here my edition is done, next part was intact /* Auto login user */

And now it works great in joomla 2.5. Can you suggest anything to modify?
Last edit: 13 years 5 months ago by Maxim.

Please Log in or Create an account to join the conversation.

More
13 years 5 months ago #3 by Chris
I am not a coder, so maybe you should wait for Antonio to reply, but it looks like you have hacked Jomsocial which I assume it is not the desired result.

Normally when you can add manually but not automatically it is because of an ordering conflict between one or more plugins. The solution is typically to find which plugin needs to come first by disabling the other plugins to ensure it works and then enabling them one at a time to find the order.

As you said joomdlehooks is not being called and thus it is likely that this plugin needs to be in front of the plugin causing it to be avoided.

Also, looking at your code it is not totally logically that you should login before you register. In otherwords you login using jomsocial but you are not registered yet in Moodle. It is more logical to register in joomla followed by moodle and then login. This supports my earlier comment about the order of the plugins being used.

Please Log in or Create an account to join the conversation.

More
13 years 5 months ago #4 by Antonio Durán
Replied by Antonio Durán on topic Joomla users are not created in Moodle automatically
Chris is right: check the order of plugins.

Also disable profile types integration and test, as this may be the problem.

Please Log in or Create an account to join the conversation.