Topic-icon JomSocial Plugin not copying values on "connect"

Active Subscriptions:

None
The JomSocial plugin works fine when logging in to my site via JFBC.

But if I login via Joomla (with a not mapped user) and press the "Connect" button on SCLogin Module, the user is mapped correctly, but the values are not copied from FB to the JomSocial fields.

I have the "Always Import Profile Data" setting on JomSocial Plugin set to YES.
Both component, modules and plugins are updated to the latest release.

Is this the expected behaviour?
The topic has been locked.
Support Specialist
11 years 2 months ago #30887 by alzander
It's the expected behavior right now. It will still work that way in the 5.0 release, coming out in a week. However, with that release, it would take about 3 lines of code to import the profile when the user 'connects' accounts. That's something we're planning to fully implement in an upcoming release, but there were some questions on our end for the best settings to use. Mainly, if there should be a separate setting for "Import on 'connect'" in addition to the register and login settings. That way, there's a way to import the profile only once when the user initially 'connects' their account, if desired.

Hope that makes sense. When the 5.0 release is out, feel free to update this thread, and we'll give you the code that (should) do exactly what you're looking for.

Alex
The topic has been locked.
Active Subscriptions:

None

alzander wrote: When the 5.0 release is out, feel free to update this thread, and we'll give you the code that (should) do exactly what you're looking for.


5.0 is out and installed :)
Here I am requesting said lines of code :)

Or, if you have a solution for my thread www.sourcecoast.com/forums/jfbconnect/jf...s-on-connect-profile , I'll manage that via a plugin.

I am not a fan of hacking directly your code: when I update a release I tend to forget to restore such hacks ;)
The topic has been locked.
Support Specialist
11 years 1 month ago #31333 by alzander
The changes are simple (hopefully), and we'd love your feedback. Basically, if you have "Always Import" enabled, this will simply call the onLogin event in the social profiles, which should then import as expected.

Edit /components/com_jfbconnect/controllers/loginregister.php At line 341, you'll see:
} else //Logged in successfully
        {
            /* Don't import on just a mapping update, for now. Need to investigate.
            $jUser = JFactory::getUser();
            $jfbcLibrary = JFBConnectFacebookLibrary::getInstance();
            $fbUserId = $jfbcLibrary->getMappedFbUserId();
            $args = array($jUser->get('id'), $fbUserId);

            JPluginHelper::importPlugin('jfbcprofiles');
            $app->triggerEvent('scProfilesImportProfile', $args);
            $app->enqueueMessage('Profile Imported!');*/

            JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_jfbconnect/' . 'models');
That big block of code that's commented out should be removed/replaced as below. When done, it should look like:
} else //Logged in successfully
        {
            JPluginHelper::importPlugin('socialprofiles');
            $jUser = JFactory::getUser();
            $jfbcLibrary = JFBConnectFacebookLibrary::getInstance();
            $fbUserId = $jfbcLibrary->getMappedFbUserId();
            $args = array('facebook', $jUser->get('id'), $fbUserId);
            $app->triggerEvent('socialProfilesOnLogin', $args);

            JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_jfbconnect/' . 'models');
We'll likely be adding this in the next release, we just didn't want to change the behavior with this release with all the other changes going on already. Your feedback would be great on if it works as you'd expect.

Good luck with either this code change or the suggestions from the other thread.

Alex
The topic has been locked.
Active Subscriptions:

None
Sorry, but no results what-so-ever.

I am a bit confused :(
I cannot find the code that is actually run.

First of all, I am testing like this:
1. I login to Joomla with a user+password login
2. If the user I am testing is allready mapped, I just go to "user map" on the backend and delete this user's mapping, so the "Connect to social network" button on SCLogin Module becomes available;
3. I press the "Connect to social network" button on SCLogin Module

Now, since the code changes you suggested are not working I placed a few PHP around components/com_jfbconnect/controllers/loginregister.php
trigger_error('Say hello to my little friend', E_ERROR);
a) just after the $app->triggerEvent('socialProfilesOnLogin', $args) on the code you provided me with;
b) at line 121, just before $app->enqueueMessage(JText::_('COM_JFBCONNECT_MAP_USER_SUCCESS'));
c) at line 272, also just before $app->enqueueMessage(JText::_('COM_JFBCONNECT_MAP_USER_SUCCESS'));

Now, I always get the COM_JFBCONNECT_MAP_USER_SUCCESS message when I map the user, but no news from those triggers...

What am I missing, here?
JFBConnect is 5.0 and Joomla is 2.5
The topic has been locked.
Active Subscriptions:

None
Ahaaaaaaaaa! GOT IT!

We must edit the controller, boys and girls!

File /components/com_jfbconnect/controller.php - at line 104 change this
if ($userMapModel->mapUser($fbUserId))
    $app->enqueueMessage(JText::_('COM_JFBCONNECT_MAP_USER_SUCCESS'));
else
    $app->enqueueMessage(JText::_('COM_JFBCONNECT_MAP_USER_FAIL'));

to this
if ($userMapModel->mapUser($fbUserId)) {
    JPluginHelper::importPlugin('socialprofiles');
    $args = array('facebook', $user->id, $fbUserId);
    $app->triggerEvent('socialProfilesOnLogin', $args);
    $app->enqueueMessage(JText::_('COM_JFBCONNECT_MAP_USER_SUCCESS'));
  } else
    $app->enqueueMessage(JText::_('COM_JFBCONNECT_MAP_USER_FAIL'));

Yessssssssssssss!
Working ok, so far...
The topic has been locked.
Support Specialist
11 years 1 month ago #31435 by alzander
Glad you got it going. I gave you the proper code in your other thread as well. Sorry for the confusion though. Both topics are pretty similar though, so I probably got crossed on my answers a little too.

Thanks,
Alex
The topic has been locked.