Topic-icon Plugin Events on Connect Profile

Active Subscriptions:

None
Hi,

When a user connects his/hers joomla user to FB, is this triggering any JFBConnect events that I can use on my own JFBConnect plugin?

Essentially, I need run the same code I run on jfbcProfilesOnRegister() if a user registers via Joomla and connects via JFBConnect later in life.

Any tips?

Thanks a lot.
The topic has been locked.
Support Specialist
11 years 1 month ago #31332 by alzander
In the 5.0 release, the Profile plugins have changed drastically.. and for the better.

The new profile plugins have similar functions as before, but are structured better and generally require less code. The jfbcProfilesOnRegister function is now "socialProfilesOnRegister" and there is a "socialProfilesOnLogin". The onLogin call is done whenever a user logs in, but not if it's their first registration.

So, what I'd recommend is adding your function to fire on both the socialProfilesOnLogin and socialProfilesOnRegister and then, in the OnLogin function, you also check if whatever you're doing is really required. So, for instance, if you're creating a row in some other db table when a user registers, in the onLogin call, make sure that row doesn't already exist.

Look over the new code though in the socialprofile plugins we have. The calls for socialProfilesOnRegister is generally not in the actual plugins; those calls are in the base class that you can find in /libraries/sourcecoast/plugins/socialprofile.php

I hope that helps get you started. We're planning to overhaul the documentation for creating a profile plugin since those are the new base for profile imports in both JFBConnect and JLinked, and we're planning more social network support in the future. So, those plugins will allow importing from many networks into Joomla and will need great documentation to get other developers on board.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
I'm sorry, Alzander but from your reply is still not clear for me:

- is there an event triggered when a usar connects his/hers joomla user to FB? (by pressing the connect button on mod_sclogin, when already logged in via Joomla)

And
- the "socialProfilesOnLogin" is triggered only on Facebook/LinkedIn logins, or is it triggered also via a "username+password" login on mod_sclogin?

Thanks again!
The topic has been locked.
Support Specialist
11 years 1 month ago #31348 by alzander
Alexandre,
Frankly, I don't know what the hell I was rambling about earlier. Sorry about that. Early morning.

No, there isn't a trigger right now when a user clicks the "Connect" button from the SCLogin module. I just looked at the code, it's missing. I'm not sure why and I think it's just been something long overlooked. I have another code change that you can implement, test, and let us know about that will trigger the 'socialProfilesOnLogin' event, which will import data and do any other login actions you want. Definitely something I can see adding to the next release, but again, would love your feedback.

If so, edit /components/com_jfbconnect/controller.php. Around line 101 is:
} else # Already logged into Joomla. Update their facebook mapping
        {
            SCSocialUtilities::clearJFBCNewMappingEnabled();
            if ($userMapModel->mapUser($fbUserId))
                $app->enqueueMessage(JText::_('COM_JFBCONNECT_MAP_USER_SUCCESS'));
            else
Update that similarly to the other thread I responded to to add the trigger you're looking for:
} else # Already logged into Joomla. Update their facebook mapping
        {
            SCSocialUtilities::clearJFBCNewMappingEnabled();
            if ($userMapModel->mapUser($fbUserId))
           {  // Add this
                $args = array('facebook', $jUserId, $fbUserId);  // Add this
                $app->triggerEvent('socialProfilesOnLogin', $args);  // Add this
                
                $app->enqueueMessage(JText::_('COM_JFBCONNECT_MAP_USER_SUCCESS'));
           }  // Add this
           else
Hope that helps,
Alex
The topic has been locked.
Support Specialist
11 years 1 month ago #31349 by alzander
Oh, and the socialProfilesOnLogin function is *not* called when you login using the username+password function. That is a strictly Joomla only login. The code change above will make it so if the user logs in through username+password and then clicks the "Connect this account to your Social Network" facebook link.

Alex
The topic has been locked.