Topic-icon New Jlinked question

Active Subscriptions:

None
11 years 1 month ago #31419 by jwhelan
New Jlinked question was created by jwhelan
It's great to see that the next version of JLinked has been released. Does it automatically connect the uesr's JLinked account to his existing Joomla account?

- JW
The topic has been locked.
Support Specialist
11 years 1 month ago #31589 by alzander
Replied by alzander on topic New Jlinked question
JW,
Sorry for the delay in responding. No, this release doesn't have that feature. We planned to add that and the ability to auto-create accounts. The migration to the "Social Profile" plugins and the compatibility with Joomla 3.0 proved too much to test, implement, and be confident with for this release. We are planning the next 2.1 release of JLinked though which will definitely have these features. With the new Social Profile plugins, that makes things much easier to develop since they are compatible with JFBConnect and simply require less development and testing going forward.

With all that said, if you just want the automatic mapping by email.. so that if a user clicks the Login with LinkedIn button and already has a Joomla account on your site with the same email address, they will be automatically associated and logged in, we can help you now.

The code below has been tested, but not thoroughly gone through all our checks and full test suite. It should do what you're looking for though. To implement, edit the /components/com_jlinked/controller.php file. In the loginLinkedInUser function, around like 56, you'll see:
if ($jUserId == null)
            { # User not in system, create new users setting enabled. Redirect to the login/register form
Directly *above* that, add the following big ole' block of code. I left the 2 lines above at the bottom of the block so you can see how it flows.
if (!$jUserId)
            {
                $profileLibrary = JLinkedProfileLibrary::getInstance();
                $linkedInProfile = $profileLibrary->fetchProfile($liMemberId, array('email-address'));

                $liEmail = $linkedInProfile->get('email-address', null);
                if ($liEmail != null)
                {
                    $jUserEmailId = $userMapModel->getJoomlaUserIdFromEmail($liEmail);
                    if (!empty($jUserEmailId))
                    {
                        // Found a user with the same email address
                        // do final check to make sure there isn't a FB account already mapped to it
                            SCSocialUtilities::clearJLinkedNewMappingEnabled();
                            if ($userMapModel->mapUser($liMemberId, $jlinkedLibrary->getToken(), $jUserEmailId))
                                $app->enqueueMessage(JText::_('COM_JLINKED_MAP_USER_SUCCESS'));
                            else
                                $app->enqueueMessage(JText::_('COM_JLINKED_MAP_USER_FAIL'));

                            $jUserId = $jUserEmailId; // Update the temp jId so that we login below
                    }
                }
            }

            if ($jUserId == null)
            { # User not in system, create new users setting enabled. Redirect to the login/register form
Test, test, and test again. You can delete the 'mapping' in the JLinked User Map admin area. That will leave the Joomla account. On the next login with JLinked, the User Map row should be re-added.

Let us know how that goes. We're considering a 2.0.1 release with this code, and having positive feedback would help get that prioritized.

Thanks,
Alex
The topic has been locked.