Topic-icon Updating JomSocial profiles

Active Subscriptions:

None
11 years 11 months ago #22769 by jwhelan
Is there any way to have jLinked feed updated profile information to JomSocial? That way the information won't get stale over time.

-JW
The topic has been locked.
Support Specialist
11 years 11 months ago #22826 by alzander
JW,
Not right now. JLinked currently only pulls in profile information during the registration process. The reason for that is because LinkedIn is very explicit that Profile Information can only be 'pulled' with direct consent from the user each time. Therefore, we can't automatically pull it on a set interval or even when the user logs in, without some modifications to let the user choose to (or not) pull in the data.

We're hoping to have a method to let the user click a "Pull my info" type button either during login or on their JomSocial profile page itself. It's not a critical task for us, but definitely in our to-do list, as we realize that would be a nice addition to things.

Hope that answers your questions, even if it's not exactly what you wanted to hear..

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

None
11 years 11 months ago #22889 by jwhelan
Replied by jwhelan on topic Updating JomSocial profiles
A 'pull profile from LinkedIn' button to put on the JomSocial profile page would be really sweet!

I might even attempt to code it myself. If I manage to get it working I'll send you the code for your next version. Any tips on where I should start?

-JW
The topic has been locked.
Support Specialist
11 years 11 months ago #22992 by alzander
JW,
Sorry for the delay. We've been talking about this a bit and have a general flow of how we'd do this. It will take a few days, but I think we can get you some good code to implement to get it done right. Unfortunately, there isn't an easy to call function that will simply import the profile information (without doing a lot of other stuff, like registration) right now, so it's not easy to simply say "start here".

However, we should be able to help you add that function and get things going for you. We'd love to get you a solution to test because we'd love to have that feature as part of the next release of JLinked. Having ready and willing testers for new features ahead of time is always welcome :)

Thanks, and we'll keep you posted!
Alex
The topic has been locked.
Active Subscriptions:

None
11 years 11 months ago #23047 by jwhelan
Replied by jwhelan on topic Updating JomSocial profiles
Alex,

I'd be delighted to help out any I way I can. Just let me know.

- jw
The topic has been locked.
Support Specialist
11 years 10 months ago #23219 by alzander
JW,
Just wanted to get back. We've done some testing and implementing the import of profiles by a link is actually quite easy. The code below 'works'. It's not 100% how we'd do it when we implement it in the next release (explanation below of why), but it should work for you right now. Again, feedback on any improvements would be very very welcome!

Instructions:
Edit /components/com_jlinked/controller.php. At the bottom (before the final }) add this function:
function updateProfile()
    {
        $jUser = JFactory::getUser();
        $jlinkedLibrary = JLinkedApiLibrary::getInstance();
        $jlinkedLibrary->setInitialRegistration();
        $liMemberId = $jlinkedLibrary->getLinkedInMemberId();
        $args = array($jUser->get('id'), $liMemberId);

        $app = JFactory::getApplication();
        JPluginHelper::importPlugin('jlinkedprofiles');
        $app->triggerEvent('jlinkedProfilesImportProfile', $args);
        $app->enqueueMessage('Profile Imported!');
        $app->redirect('index.php');
    }
Notes:
* Feel free to update the enqueueMessage line with a blue-bar message you want the user to see "Profile imported!", or delete that line altogether.
* The last line is a hard-coded redirect for where the user should go after the redirect. Feel free to update that wherever you want on your site

Once that code is added, simply create a link anywhere on your site to the following URL:
index.php?option=com_jlinked&task=updateProfile
When navigated too, all profile plugins will be told to re-import the user's profile from LinkedIn and the user will be redirected to the page set above. If you're putting this in a template file (that supports PHP), you will likely want to add it like this:
$jlinkedLibrary = JLinkedApiLibrary::getInstance();
    $liMemberId = $jlinkedLibrary->getMappedLinkedInUserId();
    if ($liMemberId)
       echo '<a href="index.php?option=com_jlinked&task=updateProfile">Fetch Profile From LinkedIn</a>';
That code will verify that the user has already logged in with LinkedIn (and therefore can fetch their profile). If they haven't, no link will be displayed. That code for displaying the link hasn't been tested, but looks right... :)

When we implement this, we'll be:
* Removing the call to setInitialRegistration() - That's a bit of a hack to get around a check to make sure we don't import LI profiles outside of registration only.
* Set the redirect to be dynamic (likely going back to the page the import originated on, with some configuration ability to go somewhere else).
* Probably adding a {JLinkedImportProfile} tag (or something like that) to add the link as above
* (Hopefully) more flexibility on what would be imported instead of just overwriting everything. May not be in the first release of this.

Definitely test, test, test! The import code was checked quickly. The link code, not at all. Let us know how it goes for you and feedback is definitely appreciated!

Good luck,
Alex
The topic has been locked.
Active Subscriptions:

None
11 years 10 months ago #23220 by jwhelan
Replied by jwhelan on topic Updating JomSocial profiles
Alex,

Thanks a million for this. I'll work on making the modifications to my site this evening and let you know how it goes...

-John W.
The topic has been locked.
Active Subscriptions:

None
11 years 10 months ago #23221 by jwhelan
Replied by jwhelan on topic Updating JomSocial profiles
Alex,

This seems to work great. The only tweak I made was to the JomSocial part so the link only shows on the users own profile as follows:

if( $isMine ):
$jlinkedLibrary = JLinkedApiLibrary::getInstance();
$liMemberId = $jlinkedLibrary->getMappedLinkedInUserId();
if ($liMemberId)
echo '<a href="index.php?option=com_jlinked&task=updateProfile">Update profile from LinkedIn</a>';
endif;?>

You're welcome to check out my site to see how it works. I apologize in advance for the design - I'm working on that. Right now, I'm trying to get all the pieces working as they should. I'll PM you with the details.

Best.

- John W.
The topic has been locked.
Support Specialist
11 years 10 months ago #23222 by alzander
John,
Awesome! Very glad to hear that worked. I was a bit surprised how easy it was to get setup, in all honesty. I guess we can pat ourselves on the back for easy-to-use code :)

This will definitely be a part of the next 'big' release (likely not a bug-fix though), so if you upgrade, look for it as a feature.. which may be implemented differently (but hopefully better, where we can improve it). Until then, if we do have a bug release, you'll need to re-implement that code.

Definitely keep us posted on any other suggestions or ideas you come up with and thanks again for all of your feedback!

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

None
11 years 10 months ago #23225 by jwhelan
Replied by jwhelan on topic Updating JomSocial profiles
I really like how well jLinked integrated with my site. Do you have any plans for some additional Joomla/LinkedIn plugins or modules that work with jLinked? I can think of one or two that I'd love to see - I'd even prepay for them if it helped spur development.

-John W.
The topic has been locked.